[open-ils-commits] r12963 - trunk/Open-ILS/src/perlmods/OpenILS/Application (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 22 12:46:59 EDT 2009


Author: miker
Date: 2009-04-22 12:46:56 -0400 (Wed, 22 Apr 2009)
New Revision: 12963

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
Log:
teach the batch processor to ignore targets with existing events (pending for active, any for passive) for the def in question

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-04-22 16:36:05 UTC (rev 12962)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm	2009-04-22 16:46:56 UTC (rev 12963)
@@ -384,6 +384,20 @@
         }
 
         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') : ())
+			}
+		}
+	};
+
         $class =~ s/^Fieldmapper:://o;
         $class =~ s/::/_/go;
 
@@ -393,30 +407,9 @@
         for my $o (@$objects) {
 
             my $ident = $o->Identity;
-            my $ident_value = $o->$ident();
 
-            my $previous;
-            if ($active) {
-                # only allow one pending event of type $def for each target
-                $previous = $editor->search_action_trigger_event({
-                    event_def => $def->id,
-                    target    => $ident_value,
-                    state     => 'pending'
-                });
-
-            } else {
-                # only allow one event of type $def for each target
-                $previous = $editor->search_action_trigger_event({
-                    event_def => $def->id,
-                    target    => $ident_value
-                });
-
-            }
-
-            next if (ref($previous) && @$previous);
-
             my $event = Fieldmapper::action_trigger::event->new();
-            $event->target( $ident_value );
+            $event->target( $o->$ident() );
             $event->event_def( $def->id );
             $event->run_time( $run_time );
 



More information about the open-ils-commits mailing list