[open-ils-commits] r14781 - in trunk/Open-ILS/src: perlmods/OpenILS/Application perlmods/OpenILS/Application/Trigger sql/Pg (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Nov 4 21:43:23 EST 2009


Author: erickson
Date: 2009-11-04 21:43:21 -0500 (Wed, 04 Nov 2009)
New Revision: 14781

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm
   trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:

removed validator version of max delay age
replaced max delay params with max delay column in seed data for default overdue/courtesy notices
sort between params in trigger max-delay by oldest date first



Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm	2009-11-04 22:52:49 UTC (rev 14780)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Validator.pm	2009-11-05 02:43:21 UTC (rev 14781)
@@ -14,7 +14,6 @@
     my $env = shift;
 
     return 0 if (defined($env->{target}->checkin_time));
-    return 0 if ($env->{params}->{max_delay_age} && !$self->MaxPassiveDelayAge($env));
 
     if ($env->{params}->{min_target_age}) {
         $env->{params}->{target_age_field} = 'xact_start';
@@ -24,25 +23,6 @@
     return 1;
 }
 
-sub MaxPassiveDelayAge {
-    my $self = shift;
-    my $env = shift;
-    my $target = $env->{target};
-    my $delay_field = $env->{event}->event_def->delay_field;
-
-    my $delay_field_ts = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($target->$delay_field()));
-
-    # the cutoff date is the target timestamp + the delay + the max_delay_age
-    # This is also true for negative delays. For example:
-    #    due_date + "-3 days" + "1 day" == -2 days old.
-    $delay_field_ts
-        ->add( seconds => interval_to_seconds( $env->{event}->event_def->delay ) )
-        ->add( seconds => interval_to_seconds( $env->{params}->{max_delay_age} ) );
-
-    return 1 if $delay_field_ts > DateTime->now;
-    return 0;
-}
-
 sub MinPassiveTargetAge {
     my $self = shift;
     my $env = shift;
@@ -65,7 +45,6 @@
 
     return 0 if $circ->checkin_time;
     return 0 if $circ->stop_fines and not $circ->stop_fines =~ /MAXFINES|LONGOVERDUE/;
-    return 0 if ($env->{params}->{max_delay_age} && !$self->MaxPassiveDelayAge($env));
 
     if ($env->{params}->{min_target_age}) {
         $env->{params}->{target_age_field} = 'xact_start';

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-11-04 22:52:49 UTC (rev 14780)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-11-05 02:43:21 UTC (rev 14781)
@@ -391,8 +391,8 @@
                 my @times = sort {$a <=> $b} interval_to_seconds($def->delay), interval_to_seconds($def->max_delay);
                 $filter->{ $def->delay_field } = {
                     'between' => [
-                        DateTime->now->subtract( seconds => $times[0] )->strftime( '%F %T%z' ),
-                        DateTime->now->subtract( seconds => $times[1] )->strftime( '%F %T%z' )
+                        DateTime->now->subtract( seconds => $times[1] )->strftime( '%F %T%z' ),
+                        DateTime->now->subtract( seconds => $times[0] )->strftime( '%F %T%z' )
                     ]
                 };
             } else {

Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-11-04 22:52:49 UTC (rev 14780)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql	2009-11-05 02:43:21 UTC (rev 14781)
@@ -1901,8 +1901,8 @@
 
 -- Sample Overdue Notice --
 
-INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template) 
-    VALUES (1, 'f', 1, '7 Day Overdue Email Notification', 'checkout.due', 'CircIsOverdue', 'SendEmail', '7 days', 'due_date', 'usr', 
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, max_delay, template) 
+    VALUES (1, 'f', 1, '7 Day Overdue Email Notification', 'checkout.due', 'CircIsOverdue', 'SendEmail', '7 days', '8 days', 'due_date', 'usr', 
 $$
 [%- USE date -%]
 [%- user = target.0.usr -%]
@@ -1930,9 +1930,6 @@
     (1, 'billable_transaction.summary'),
     (1, 'circ_lib.billing_address');
 
-INSERT INTO action_trigger.event_params (event_def, param, value) VALUES
-    (1, 'max_delay_age', '"1 day"');
-
 -- Sample Mark Long-Overdue Item Lost --
 
 INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field) 
@@ -2340,8 +2337,8 @@
 
 -- Sample Pre-due Notice --
 
-INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template) 
-    VALUES (6, 'f', 1, '3 Day Courtesy Notice', 'checkout.due', 'MaxPassiveDelayAge', 'SendEmail', '-3 days', 'due_date', 'usr', 
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, max_delay, template) 
+    VALUES (6, 'f', 1, '3 Day Courtesy Notice', 'checkout.due', 'MaxPassiveDelayAge', 'SendEmail', '-3 days', 'due_date', 'usr', '-2 days',
 $$
 [%- USE date -%]
 [%- user = target.0.usr -%]
@@ -2368,10 +2365,6 @@
     (6, 'usr'),
     (6, 'circ_lib.billing_address');
 
-INSERT INTO action_trigger.event_params (event_def, param, value) VALUES
-    (6, 'max_delay_age', '"1 day"');
-  
-
 -- ApplyPatronPenalty A/T Reactor
 
 INSERT INTO action_trigger.reactor (module,description) VALUES ('ApplyPatronPenalty','Applies the conifigured penalty to a patron.  Required named environment variables are "user", which refers to the user object, and "context_org", which refers to the org_unit object that acts as the focus for the penalty.');



More information about the open-ils-commits mailing list