JBAS-916 Holds max loops linger on checked out
authorBill Erickson <berickxx@gmail.com>
Mon, 5 Oct 2015 21:56:43 +0000 (17:56 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
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 <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm

index 3b300be..a2ec99d 100644 (file)
@@ -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 ) {