From: phasefx Date: Wed, 14 Apr 2010 16:22:50 +0000 (+0000) Subject: Rework clear_hold_shelf process so that it looks for eligible holds for the cleared... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=723670fba501ba0ef9133af7f1a3281e148ff0e2;p=evergreen%2Ftadl.git Rework clear_hold_shelf process so that it looks for eligible holds for the cleared copies after the transaction updating the existing holds and copies has committed. Also fixed the copy_status test so that Available works as a value for circ.holds.clear_shelf.copy_status git-svn-id: svn://svn.open-ils.org/ILS/trunk@16236 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 6141c61add..f2b188617a 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -1883,7 +1883,7 @@ sub find_nearest_permitted_hold { # 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", + "open-ils.storage.action.hold_request.nearest_hold.atomic", $user->ws_ou, $copy->id, 10, $hold_stall_interval ); unless(@$best_holds) { @@ -2217,7 +2217,7 @@ sub clear_shelf_process { my $copy = $hold->current_copy; - if($copy_status) { + if($copy_status or $copy_status == 0) { # if a clear-shelf copy status is defined, update the copy $copy->status($copy_status); $copy->edit_date('now'); @@ -2225,50 +2225,59 @@ sub clear_shelf_process { $e->update_asset_copy($copy) or return $e->die_event; } - my ($alt_hold) = __PACKAGE__->find_nearest_permitted_hold($e, $copy, $e->requestor, 1); + push(@holds, $hold); + } - if($alt_hold) { + if ($e->commit) { - # copy is needed for a hold - $client->respond({action => 'hold', copy => $copy, hold_id => $hold->id}); + for my $hold (@holds) { - } elsif($copy->circ_lib != $e->requestor->ws_ou) { + my $copy = $hold->current_copy; - # copy needs to transit - $client->respond({action => 'transit', copy => $copy, hold_id => $hold->id}); + my ($alt_hold) = __PACKAGE__->find_nearest_permitted_hold($e, $copy, $e->requestor, 1); - } else { + if($alt_hold) { + + # copy is needed for a hold + $client->respond({action => 'hold', copy => $copy, hold_id => $hold->id}); - # copy needs to go back to the shelf - $client->respond({action => 'shelf', copy => $copy, hold_id => $hold->id}); + } elsif($copy->circ_lib != $e->requestor->ws_ou) { + + # copy needs to transit + $client->respond({action => 'transit', copy => $copy, hold_id => $hold->id}); + + } else { + + # copy needs to go back to the shelf + $client->respond({action => 'shelf', copy => $copy, hold_id => $hold->id}); + } } - push(@holds, $hold); - } + # tell the client we're done + $client->respond_complete; - $e->commit; + # fire off the hold cancelation trigger + my $trigger = OpenSRF::AppSession->connect('open-ils.trigger'); - # tell the client we're done - $client->respond_complete; + for my $hold (@holds) { - # fire off the hold cancelation trigger - my $trigger = OpenSRF::AppSession->connect('open-ils.trigger'); + my $req = $trigger->request( + 'open-ils.trigger.event.autocreate', + 'hold_request.cancel.expire_holds_shelf', + $hold, $org_id); - for my $hold (@holds) { + # wait for response so don't flood the service + $req->recv; + } - my $req = $trigger->request( - 'open-ils.trigger.event.autocreate', - 'hold_request.cancel.expire_holds_shelf', - $hold, $org_id); + $trigger->disconnect; - # wait for response so don't flood the service - $req->recv; + } else { + # tell the client we're done + $client->respond_complete; } - - $trigger->disconnect; } - __PACKAGE__->register_method( method => 'usr_hold_summary', api_name => 'open-ils.circ.holds.user_summary',