From 11c9d08d61d0d8fa9a4d68c42367e398b930e2d5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 14 Dec 2011 13:36:05 -0500 Subject: [PATCH] Process still-shelved, canceled holds in clear-shelf process Holds that are canceled but still physically on the hold shelf are processed like other holds during the clear-shelf process. They will be grouped in the same manner and if a custom post-clear status is configured, copies linked to already-canceled holds will get the custom status. The only difference is already-canceled holds will not be re-canceled during the clear-shelf process. This change has the added benefit of leveraging another API call to retrieve the shelf-expired holds instead of using its own custom json-query. See https://bugs.launchpad.net/evergreen/+bug/904332 Signed-off-by: Bill Erickson Signed-off-by: Thomas Berezansky --- .../lib/OpenILS/Application/Circ/Holds.pm | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 0a6bdfc4ce..2004cebc30 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -3283,23 +3283,15 @@ sub clear_shelf_process { my $copy_status = $U->ou_ancestor_setting_value($org_id, 'circ.holds.clear_shelf.copy_status'); - # Find holds on the shelf that have been there too long - my $hold_ids = $e->search_action_hold_request( - { shelf_expire_time => {'<' => 'now'}, - pickup_lib => $org_id, - cancel_time => undef, - fulfillment_time => undef, - shelf_time => {'!=' => undef}, - capture_time => {'!=' => undef}, - current_copy => $current_copy, - }, - { idlist => 1 } - ); + my @hold_ids = $self->method_lookup( + "open-ils.circ.captured_holds.id_list.expired_on_shelf.retrieve" + )->run($auth, $org_id); my @holds; + my @canceled_holds; # newly canceled holds my $chunk_size = 25; # chunked status updates my $counter = 0; - for my $hold_id (@$hold_ids) { + for my $hold_id (@hold_ids) { $logger->info("Clear shelf processing hold $hold_id"); @@ -3310,10 +3302,13 @@ sub clear_shelf_process { } ]); - $hold->cancel_time('now'); - $hold->cancel_cause(2); # Hold Shelf expiration - $e->update_action_hold_request($hold) or return $e->die_event; - delete_hold_copy_maps($self, $e, $hold->id) and return $e->die_event; + if (!$hold->cancel_time) { # may be canceled but still on the holds shelf + $hold->cancel_time('now'); + $hold->cancel_cause(2); # Hold Shelf expiration + $e->update_action_hold_request($hold) or return $e->die_event; + delete_hold_copy_maps($self, $e, $hold->id) and return $e->die_event; + push(@canceled_holds, $hold_id); + } my $copy = $hold->current_copy; @@ -3369,7 +3364,7 @@ sub clear_shelf_process { # refetch the holds to pick up the caclulated cancel_time, # which may be needed by Action/Trigger $e->xact_begin; - my $updated_holds = $e->search_action_hold_request({id => $hold_ids}, {substream => 1}); + my $updated_holds = $e->search_action_hold_request({id => \@canceled_holds}, {substream => 1}); $e->rollback; $U->create_events_for_hook( -- 2.43.2