From a7c326727ab6bdda2c9899ceba7ddb6fc84ffd58 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 11 Dec 2013 12:58:49 -0500 Subject: [PATCH] LP#1261486 Action/trigger aggregator script repairs * If both date filters are selected, apply both instead of replacing the first with the second * Select distinct event output to prevent dupes Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../action_trigger_aggregator.pl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/support-scripts/action_trigger_aggregator.pl b/Open-ILS/src/support-scripts/action_trigger_aggregator.pl index aebf235e8f..4a53454f35 100755 --- a/Open-ILS/src/support-scripts/action_trigger_aggregator.pl +++ b/Open-ILS/src/support-scripts/action_trigger_aggregator.pl @@ -143,14 +143,28 @@ print "Processing event-defs @event_defs\n" if $verbose; my %date_filter; $date_filter{run_time} = {'>=' => $start_date} if $start_date; -$date_filter{run_time} = {'<' => $end_date} if $end_date; + +if ($end_date) { + if ($date_filter{run_time}) { + # both filters requested, -and them together + $date_filter{'-and'} = [ + {run_time => delete $date_filter{run_time}}, + {run_time => {'<' => $end_date}} + ]; + } else { + $date_filter{run_time} = {'<' => $end_date}; + } +} + # collect the event tempate output data # use a real session here so we can stream results directly to the output file my $ses = OpenSRF::AppSession->create('open-ils.cstore'); my $req = $ses->request( 'open-ils.cstore.json_query', { - select => {ateo => ['data']}, + select => {ateo => [ + # ateo's may be linked to multiple atev's; select distinct. + {column => 'id', transform => 'distinct'}, 'data']}, from => {ateo => { atev => { filter => {state => 'complete', %date_filter}, join => {atevdef => {filter => { -- 2.43.2