my $fifo = $U->ou_ancestor_setting_value($user->ws_ou, 'circ.holds_fifo');
# search for what should be the best holds for this copy to fulfill
- my $best_holds = $U->storagereq(
- "open-ils.storage.action.hold_request.nearest_hold.atomic",
- $user->ws_ou, $copy->id, 10, $hold_stall_interval, $fifo );
-
- unless(@$best_holds) {
-
- if( my $hold = $$old_holds[0] ) {
- $logger->info("circulator: using existing pre-targeted hold ".$hold->id." in hold search");
- return ($hold);
- }
-
- $logger->info("circulator: no suitable holds found for copy $bc");
- return (undef, $evt);
- }
-
-
+ my $offset = 0;
my $best_hold;
+ my $found_none;
+ until ($best_hold) {
- # for each potential hold, we have to run the permit script
- # to make sure the hold is actually permitted.
- my %reqr_cache;
- my %org_cache;
- for my $holdid (@$best_holds) {
- next unless $holdid;
- $logger->info("circulator: checking if hold $holdid is permitted for copy $bc");
-
- my $hold = $editor->retrieve_action_hold_request($holdid) or next;
- my $reqr = $reqr_cache{$hold->requestor} || $editor->retrieve_actor_user($hold->requestor);
- my $rlib = $org_cache{$hold->request_lib} || $editor->retrieve_actor_org_unit($hold->request_lib);
-
- $reqr_cache{$hold->requestor} = $reqr;
- $org_cache{$hold->request_lib} = $rlib;
-
- # see if this hold is permitted
- my $permitted = OpenILS::Utils::PermitHold::permit_copy_hold(
- { patron_id => $hold->usr,
- requestor => $reqr,
- copy => $copy,
- pickup_lib => $hold->pickup_lib,
- request_lib => $rlib,
- retarget => 1
- }
- );
+ my $best_holds = $U->storagereq(
+ "open-ils.storage.action.hold_request.nearest_hold.atomic",
+ $user->ws_ou, $copy->id, 10, $hold_stall_interval, $fifo, $offset );
+
+ $offest += 10;
- if( $permitted ) {
- $best_hold = $hold;
- last;
+ unless(@$best_holds) {
+
+ if( my $hold = $$old_holds[0] ) {
+ $logger->info("circulator: using existing pre-targeted hold ".$hold->id." in hold search");
+ return ($hold);
+ }
+
+ $logger->info("circulator: no suitable holds found for copy $bc");
+ return (undef, $evt);
+ }
+
+ # for each potential hold, we have to run the permit script
+ # to make sure the hold is actually permitted.
+ my %reqr_cache;
+ my %org_cache;
+ for my $holdid (@$best_holds) {
+ next unless $holdid;
+ $logger->info("circulator: checking if hold $holdid is permitted for copy $bc");
+
+ my $hold = $editor->retrieve_action_hold_request($holdid) or next;
+ my $reqr = $reqr_cache{$hold->requestor} || $editor->retrieve_actor_user($hold->requestor);
+ my $rlib = $org_cache{$hold->request_lib} || $editor->retrieve_actor_org_unit($hold->request_lib);
+
+ $reqr_cache{$hold->requestor} = $reqr;
+ $org_cache{$hold->request_lib} = $rlib;
+
+ # see if this hold is permitted
+ my $permitted = OpenILS::Utils::PermitHold::permit_copy_hold(
+ { patron_id => $hold->usr,
+ requestor => $reqr,
+ copy => $copy,
+ pickup_lib => $hold->pickup_lib,
+ request_lib => $rlib,
+ retarget => 1
+ }
+ );
+
+ if( $permitted ) {
+ $best_hold = $hold;
+ last;
+ }
}
}
-
unless( $best_hold ) { # no "good" permitted holds were found
if( my $hold = $$old_holds[0] ) { # can we return a pre-targeted hold?
$logger->info("circulator: using existing pre-targeted hold ".$hold->id." in hold search");