From: Bill Erickson Date: Mon, 5 Oct 2015 21:56:43 +0000 (-0400) Subject: JBAS-916 Holds max loops linger on checked out X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=46a89c684cf587779ce1625fbf7c2f30b1e5b393;p=working%2FEvergreen.git JBAS-916 Holds max loops linger on checked out Avoid canceling a hold that has reached its max target attempts when any copies mapped to the hold are currently checked out. Signed-off-by: Bill Erickson --- 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 3b300bedd7..a2ec99ddc7 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 @@ -1433,6 +1433,13 @@ sub new_hold_copy_targeter { $hold, $hold_copy_map ); + # KCLS: List of mapped copies that are considered active + # enough to keep the hold alive (below) even if we have + # reached the maximum target loops. Currently limited to + # checked out copies. Capture them here before the + # definition of $all_copies changes below. + my @active_copies = grep { $_->status == 1 } @$all_copies; + $all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && ( $_->status == 0 || $_->status == 7 ) } @good_copies ]; my $min_prox = [ sort {$a<=>$b} keys %$prox_list ]->[0]; @@ -1502,7 +1509,16 @@ sub new_hold_copy_targeter { $current_loop++ if (!@keepers); - if ($self->{max_loops}{$pu_lib} && $self->{max_loops}{$pu_lib} >= $current_loop) { + # KCLS: avoid canceling a hold that has reached max + # loops if any mapped copies are currently checked out. + # The assumption is that a checked out copy will likely + # be returned and usable at some point (unlike available + # copies that are never pulled because they are really + # missing, etc.). + if (@active_copies or ( + $self->{max_loops}{$pu_lib} && + $self->{max_loops}{$pu_lib} >= $current_loop)) { + # We haven't exceeded max_loops yet my @keeper_copies; for my $cp ( @$all_copies ) {