From: erickson Date: Sun, 25 Oct 2009 19:01:54 +0000 (+0000) Subject: when testing for existing events (to prevent duplicates) don't test for the presence... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f91bc28d1e2c48c0f93476946e2f0cdd4f608aed;p=Evergreen.git 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 git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6_0@14591 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 a1850ba217..e821d4600d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm @@ -7,7 +7,7 @@ use OpenSRF::EX qw/:try/; 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 @@ sub create_batch_events { { 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 @@ 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') : ()) - } - } - }; + # 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 ); - - for my $o (@$objects) { + my $object_ids = $editor->$method( $filter, {idlist => 1, timeout => 1800} ); - my $ident = $o->Identity; + for my $o_id (@$object_ids) { 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 );