From 868a8193b24b515dcedea0794dc329beedbe8526 Mon Sep 17 00:00:00 2001 From: gmc Date: Fri, 24 Sep 2010 16:37:23 +0000 Subject: [PATCH] improve hold targetting * all potential capturable copies are now checked (up to the first one that is permitted for the request), instead of a small random subset of them * don't do redundant permission checks Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/trunk@17954 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Storage/Publisher/action.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 471adc80f..782eaff5d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -1868,17 +1868,19 @@ sub choose_nearest_copy { next unless (@capturable); my $rand = int(rand(scalar(@capturable))); - while (my ($c) = splice(@capturable,$rand)) { - return $c if ( OpenILS::Utils::PermitHold::permit_copy_hold( + my %seen = (); + while (my ($c) = splice(@capturable, $rand, 1)) { + return $c if !exists($seen{$c->id}) && ( 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, copy => $c->to_fieldmapper, requestor => $hold->requestor->to_fieldmapper, request_lib => $hold->request_lib->to_fieldmapper, - pickup_lib => $hold->pickup_lib->id, + pickup_lib => $hold->pickup_lib->id, } )); + $seen{$c->id}++; last unless(@capturable); $rand = int(rand(scalar(@capturable))); -- 2.11.0