[open-ils-commits] r16236 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 14 12:22:53 EDT 2010


Author: phasefx
Date: 2010-04-14 12:22:50 -0400 (Wed, 14 Apr 2010)
New Revision: 16236

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
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


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2010-04-14 13:42:35 UTC (rev 16235)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2010-04-14 16:22:50 UTC (rev 16236)
@@ -1883,7 +1883,7 @@
 
 	# 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 @@
 
         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 @@
             $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 needs to go back to the shelf
-            $client->respond({action => 'shelf', copy => $copy, hold_id => $hold->id});
+                # copy is needed for a hold
+                $client->respond({action => 'hold', 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',



More information about the open-ils-commits mailing list