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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Oct 21 13:05:29 EDT 2009


Author: miker
Date: 2009-10-21 13:05:26 -0400 (Wed, 21 Oct 2009)
New Revision: 14537

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
Cleaning up some syntax thinkos from earlier commit which added support
for hold target weighting and max hold targeting loops.

Added closed-date check condition such that if a library is closed both
now and at the next expected check time the location is ignored for
targetting.  This differs from before in that we were only checking to
see if the library was currently closed.  For 24h retargetting, this is
nominally not a change, but for longer-that-one-day retargetting intervals
this will allow a library that is open at the beginning /or/ the end of the
targetting interval to have a chance at capturing the requested copy.



Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2009-10-21 16:37:09 UTC (rev 14536)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2009-10-21 17:05:26 UTC (rev 14537)
@@ -1,6 +1,6 @@
 package OpenILS::Application::Storage::Publisher::action;
-use base qw/OpenILS::Application::Storage::Publisher/;
-use OpenSRF::Utils::Logger qw/:level/;
+#use base qw/OpenILS::Application::Storage::Publisher/;
+#use OpenSRF::Utils::Logger qw/:level/;
 use OpenSRF::Utils qw/:datetime/;
 use OpenSRF::AppSession;
 use OpenSRF::EX qw/:try/;
@@ -879,8 +879,35 @@
 		  close_end => { '>=', 'now' } }
 	);
 
+    if ($check_expire) {
 
+        # $check_expire, if it exists, was already converted to seconds
+    	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time() + $check_expire);
+	    $year += 1900;
+    	$mon += 1;
+
+	    my $next_check_time = sprintf(
+    		'%s-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d-00',
+	    	$year, $mon, $mday, $hour, $min, $sec
+    	);
+
+
+	    my @closed_at_next = actor::org_unit::closed_date->search_where(
+		    { close_start => { '<=', $next_check_time },
+    		  close_end => { '>=', $next_check_time } }
+	    );
+
+        my @new_closed;
+        for my $c_at_n (@closed_at_next) {
+            if (grep { ''.$_->org_unit eq ''.$c_at_n->org_unit } @closed) {
+                push @new_closed, $c_at_n;
+            }
+        }
+        @closed = @new_closed;
+    }
+
 	my @successes;
+	my $actor = OpenSRF::AppSession->create('open-ils.actor');
 
 	for my $hold (@$holds) {
 		try {
@@ -1078,7 +1105,7 @@
 				$log->debug("\tNothing at the pickup lib, looking elsewhere among ".scalar(@$all_copies)." copies");
 
 				my $max_loops = $actor->request(
-					'open-ils.actor.ou_setting.ancestor_default' => $lib => 'circ.holds.max_org_unit_target_loops'
+					'open-ils.actor.ou_setting.ancestor_default' => $hold->pickup_lib => 'circ.holds.max_org_unit_target_loops'
 				)->gather(1);
 
 				if (defined($max_loops)) {
@@ -1091,7 +1118,7 @@
 					my $current_loop = $cstore->request(
 						'open-ils.cstore.json_query',
 						{ distinct => 1,
-						  select => { aufhmxl => [max] },
+						  select => { aufhmxl => ['max'] },
 						  from => 'aufhmxl',
 						  where => { hold => $hold->id}
 						}
@@ -1314,7 +1341,7 @@
 	
 			if (!scalar(@good_copies)) {
 				$client->respond("\tNo (non-current) copies available to fill the hold.\n");
-				if ( $old_best && grep {$c->id == $hold->current_copy} @$copies ) {
+				if ( $old_best && grep {$_->id == $hold->current_copy} @$copies ) {
 					$client->respond("\tPushing current_copy back onto the targeting list\n");
 					push @good_copies, asset::copy->retrieve( $old_best );
 				} else {



More information about the open-ils-commits mailing list