LP#1205072 - Action Trigger Granularity Case Sensitivity user/stompro/lp1205072-action-trig-granularity-ui
authorJosh Stompro <stomproj@larl.org>
Tue, 13 Jan 2015 19:36:40 +0000 (13:36 -0600)
committerJosh Stompro <stomproj@larl.org>
Wed, 24 Jun 2015 14:10:24 +0000 (09:10 -0500)
This change makes the granularity settings case insensitive.

To test this issue
1. Create/Modify an action trigger to have an all uppercase granularity settings.
2. Run action_trigger_runner.pl with the same granularity set to lowercase
3. Observe that the events are not processed.

After the change is applied the granularity case doesn't matter for either the event_definition
or the flag to action_trigger_runner.pl.

I didn't modify the code path for when the granularity only flag isn't set since it
never gets used, and I don't want to change what I cannot test.  Maybe the best course
of action would just be to remove that section?

Added "weekdays" option to match up with example crontab file.

Replace the release notes entry since the behavior has changed.

Signed-off-by: Josh Stompro <stomproj@larl.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm
Open-ILS/src/templates/conify/global/action_trigger/event_definition.tt2
docs/RELEASE_NOTES_NEXT/Administration/action-trigger-granularity.txt

index ed83cba..70b89a9 100644 (file)
@@ -70,7 +70,7 @@ sub create_active_events_for_object {
     );
 
     for my $def ( @$defs ) {
-        next if ($granularity && $def->granularity ne $granularity );
+        next if ($granularity && lc($def->granularity) ne lc($granularity) );
 
         if ($def->usr_field && $def->opt_in_setting) {
             my $ufield = $def->usr_field;
@@ -418,7 +418,7 @@ sub create_batch_events {
     }
 
     for my $def ( @$defs ) {
-        next if ($granularity && $def->granularity ne $granularity );
+        next if ($granularity && lc($def->granularity) ne lc($granularity) );
 
         my $date = DateTime->now->subtract( seconds => interval_to_seconds($def->delay) );
 
@@ -649,7 +649,12 @@ sub pending_events {
 
     if (defined $granularity) {
         if ($granflag) {
-            $query->[0]->{'+atevdef'} = {granularity => $granularity};
+            $query->[0]->{'+atevdef'} = {granularity => {
+              '=' => {
+                           transform => 'evergreen.lowercase',
+                               value => lc($granularity)
+                         }
+            }};
         } else {
             $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] };
         }
index 56ce24b..abf9ba7 100644 (file)
@@ -9,6 +9,7 @@
              un-translated since they are codes, not labels.  -->
         <option>hourly</option>
         <option>daily</option>
+        <option>weekdays</option>
         <option>weekly</option>
         <option>monthly</option>
         <option>yearly</option>
index 215e6c6..ddfd5b9 100644 (file)
@@ -1,11 +1,10 @@
 ==== Upgrade Notes ====
 
-The 'granularity' field in the staff client Action Trigger Event
-Definition configuration interface (Admin -> Local Administration ->
-Notifications / Action Triggers) is now case sensitive.  Previously,
-entering, for example, 'hourly' would be automatically modified to
-'Hourly'.  Now, 'hourly' and 'Hourly' are each valid, distinct values.
+The --granularity setting of the action_trigger_runner.pl is now
+case insensitive.  So events that have different settings for 
+their 'granularity' field that only differ in case
+will be processed together.
 
-This is important because the granularitiy values configured on the
-server for processing action/trigger events are case sensitive as
-well.  
+If you relied upon different events being processed seperately when
+their granularity setting differed only by case the you will need
+to modify your setup to use more distinct granularity settings.