From: miker Date: Wed, 22 Apr 2009 16:46:56 +0000 (+0000) Subject: teach the batch processor to ignore targets with existing events (pending for active... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=19fe7b314f290457fe053bf7b96a91db29333c28;p=evergreen%2Ftadl.git teach the batch processor to ignore targets with existing events (pending for active, any for passive) for the def in question git-svn-id: svn://svn.open-ils.org/ILS/trunk@12963 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm index 6dbbd69cf6..761d3b5a6d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -384,6 +384,20 @@ sub create_batch_events { } 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 @@ sub create_batch_events { 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 );