From f626087af3259753b6e8712a9b46c64f84c4276f Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 31 Jan 2007 03:35:00 +0000 Subject: [PATCH] retarget previous copy if still available git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@6836 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/action.pm | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index 14c1b241f9..ba673b6e0f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -938,6 +938,18 @@ sub new_hold_copy_targeter { if ($best) { $hold->update( { current_copy => ''.$best->id, prev_check_time => 'now' } ); $log->debug("\tUpdating hold [".$hold->id."] with new 'current_copy' [".$best->id."] for hold fulfillment."); + } elsif ( + $old_best && + action::hold_request + ->search_where( + { current_copy => $old_best->id, + fulfillment_time => undef, + cancel_time => undef, + } + ) + ) { + $hold->update( { prev_check_time => 'now', current_copy => ''.$old_best->id } ); + $log->debug( "\tRetargeting the previously targeted copy [".$old_best->id."]" ); } else { $hold->update( { prev_check_time => 'now' } ); $log->info( "\tThere were no targetable copies for the hold" ); @@ -1203,7 +1215,7 @@ sub choose_nearest_copy { my $rand = int(rand(scalar(@capturable))); while (my ($c) = splice(@capturable,$rand)) { - unless ( OpenILS::Utils::PermitHold::permit_copy_hold( + return $c if ( OpenILS::Utils::PermitHold::permit_copy_hold( { title => $c->call_number->record->to_fieldmapper, title_descriptor => $c->call_number->record->record_descriptor->next->to_fieldmapper, patron => $hold->usr->to_fieldmapper, @@ -1211,12 +1223,10 @@ sub choose_nearest_copy { requestor => $hold->requestor->to_fieldmapper, request_lib => $hold->request_lib->to_fieldmapper, } - )) { - last unless(@capturable); - $rand = int(rand(scalar(@capturable))); - next; - } - return $c; + )); + + last unless(@capturable); + $rand = int(rand(scalar(@capturable))); } } } -- 2.11.0