[open-ils-commits] r14591 - branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Oct 25 15:01:58 EDT 2009


Author: erickson
Date: 2009-10-25 15:01:54 -0400 (Sun, 25 Oct 2009)
New Revision: 14591

Modified:
   branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
Log:
when testing for existing events (to prevent duplicates) don't test for the presence of events linked to the previous event def in the loop.  when fetching targets, only fetch the identifier column since it is all that is needed to create the event (and there could be many objects for passive events).  increase the search timeout for event targets

Modified: branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-10-25 19:01:38 UTC (rev 14590)
+++ branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-10-25 19:01:54 UTC (rev 14591)
@@ -7,7 +7,7 @@
 
 use OpenSRF::AppSession;
 use OpenSRF::Utils::SettingsClient;
-use OpenSRF::Utils::Logger qw/:level/;
+use OpenSRF::Utils::Logger qw/$logger/;
 use OpenSRF::Utils qw/:datetime/;
 
 use DateTime;
@@ -359,6 +359,7 @@
         { hook   => [ keys %hook_hash ], active => 't' },
     );
 
+    my $first_loop = 1;
     for my $def ( @$defs ) {
 
         my $date = DateTime->now->subtract( seconds => interval_to_seconds($def->delay) );
@@ -390,31 +391,36 @@
 
         my $class = _fm_class_by_hint($hook_hash{$def->hook}->core_type);
 
-	# filter where this target has an event (and it's pending, for active hooks)
-	$$filter{'-and'} = [] if (!exists($$filter{'-and'}));
-	push @{ $filter->{'-and'} }, {
-		'-not-exists' => {
-			from  => 'atev',
-			where => {
-				event_def => $def->id,
-				target    => { '=' => { '+' . $hook_hash{$def->hook}->core_type => $class->Identity } },
-				($active ? (state  => 'pending') : ())
-			}
-		}
-	};
+        # filter where this target has an event (and it's pending, for active hooks)
+        if($first_loop) {
+            $$filter{'-and'} = [] if (!exists($$filter{'-and'}));
+            $first_loop = 0;
+        } else {
+            # remove the pre-existing event check for the previous event def
+            pop @{ $filter->{'-and'} };
+        }
 
+        push @{ $filter->{'-and'} }, {
+            '-not-exists' => {
+                from  => 'atev',
+                where => {
+                    event_def => $def->id,
+                    target    => { '=' => { '+' . $hook_hash{$def->hook}->core_type => $class->Identity } },
+                    ($active ? (state  => 'pending') : ())
+                }
+            }
+        };
+
         $class =~ s/^Fieldmapper:://o;
         $class =~ s/::/_/go;
 
         my $method = 'search_'. $class;
-        my $objects = $editor->$method( $filter );
+        my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 1800} );
 
-        for my $o (@$objects) {
+        for my $o_id (@$object_ids) {
 
-            my $ident = $o->Identity;
-
             my $event = Fieldmapper::action_trigger::event->new();
-            $event->target( $o->$ident() );
+            $event->target( $o_id );
             $event->event_def( $def->id );
             $event->run_time( $run_time );
 



More information about the open-ils-commits mailing list