From 80b673db266e7bb3550469629aaf8f405935ea56 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 29 Dec 2014 14:04:45 -0500 Subject: [PATCH] LP#1406367 Fine generator skips no-fines transactions Filter out any circs or booking reservations which will never be billed in the initial overdue transactions query used by the fine generator. This allows us to avoid loading rows into memory that the fine generator will ignore anyway. Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- .../Application/Storage/Publisher/action.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 3d5177e6eb..56ad4a84f4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -152,20 +152,27 @@ __PACKAGE__->register_method( # between the last circulation and the first reservation. This is # useful in conjunction with 'idlist' so the caller can tell what type # of transaction the ID refers to without having to query the DB. +# skip_no_fines - filter out transactions which will never be billed, +# e.g. circs with a $0 max fine or $0 recurring fine. sub overdue_circs { my $upper_interval = shift || '1 millennium'; my $idlist = shift; my $partition = shift; + my $skip_no_fines = shift; # Only retrieve ID's in the initial query if that's all the caller needs. my $contents = $idlist ? 'id' : '*'; + my $fines_filter = $skip_no_fines ? + 'AND recurring_fine <> 0 AND max_fine <> 0' : ''; + my $c_t = action::circulation->table; my $sql = <<" SQL"; SELECT $contents FROM $c_t WHERE stop_fines IS NULL + $fines_filter AND due_date < ( CURRENT_TIMESTAMP - grace_period ) AND fine_interval < ?::INTERVAL SQL @@ -177,11 +184,15 @@ sub overdue_circs { push (@circs, undef) if $partition; + $fines_filter = $skip_no_fines ? + 'AND fine_amount <> 0 AND max_fine <> 0' : ''; + $c_t = booking::reservation->table; $sql = <<" SQL"; SELECT $contents FROM $c_t WHERE return_time IS NULL + $fines_filter AND end_time < ( CURRENT_TIMESTAMP ) AND fine_interval IS NOT NULL AND cancel_time IS NULL @@ -1062,9 +1073,11 @@ sub generate_fines { action::circulation->search_where( { id => $circ, stop_fines => undef } ), booking::reservation->search_where( { id => $circ, return_time => undef, cancel_time => undef } ); } else { - push @circs, overdue_circs(undef, 1, 1); + push @circs, overdue_circs(undef, 1, 1, 1); } + $logger->info("fine generator processing ".scalar(@circs)." transactions"); + my %hoo = map { ( $_->id => $_ ) } actor::org_unit::hours_of_operation->retrieve_all; my $penalty = OpenSRF::AppSession->create('open-ils.penalty'); -- 2.43.2