[open-ils-commits] r17954 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (gmc)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Sep 24 12:37:26 EDT 2010


Author: gmc
Date: 2010-09-24 12:37:23 -0400 (Fri, 24 Sep 2010)
New Revision: 17954

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
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 <gmc at esilibrary.com>


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-09-24 05:49:25 UTC (rev 17953)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2010-09-24 16:37:23 UTC (rev 17954)
@@ -1868,17 +1868,19 @@
 		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)));



More information about the open-ils-commits mailing list