[open-ils-commits] r10078 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jul 18 20:58:03 EDT 2008


Author: miker
Date: 2008-07-18 20:58:02 -0400 (Fri, 18 Jul 2008)
New Revision: 10078

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
allow circ.reshelving_complete.interval ou setting to override the default reshelving delay

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2008-07-19 00:36:24 UTC (rev 10077)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2008-07-19 00:58:02 UTC (rev 10078)
@@ -121,30 +121,34 @@
 	throw OpenSRF::EX::InvalidArg ("I need an interval of more than 0 seconds!")
 		unless (interval_to_seconds( $window ));
 
+	my $setting = actor::org_unit_setting->table;
 	my $circ = action::circulation->table;
 	my $cp = asset::copy->table;
 
 	my $sql = <<"	SQL";
 		UPDATE	$cp
 		  SET	status = 0
-		  WHERE	id IN
-		  	( SELECT id FROM (
-		  		SELECT	cp.id, MAX(circ.checkin_time)
-				  FROM	$cp cp
-				  	JOIN $circ circ ON (circ.target_copy = cp.id)
-				  WHERE	circ.checkin_time IS NOT NULL
-					AND cp.status = 7
-				  GROUP BY 1
-				  	HAVING MAX(circ.checkin_time) < NOW() - CAST(? AS INTERVAL)
-			  ) AS foo
-			)
-			OR id IN
-			( SELECT	cp.id
-			    FROM	$cp cp 
-					LEFT JOIN $circ circ ON (circ.target_copy = cp.id AND circ.id IS NULL)
-			    WHERE	cp.status = 7
-			    		AND cp.create_date < NOW() - CAST(? AS INTERVAL)
-			)
+		  WHERE	id IN (
+            SELECT  id
+              FROM  (SELECT cp.id, MAX(circ.checkin_time)
+                      FROM  $cp cp
+                            JOIN $circ circ ON (circ.target_copy = cp.id)
+                            LEFT JOIN $setting setting
+                                ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
+                      WHERE circ.checkin_time IS NOT NULL
+                            AND cp.status = 7
+                      GROUP BY 1
+                      HAVING MAX(circ.checkin_time) < NOW() - CAST( COALESCE( BTRIM( setting.value,'"' ), ? )  AS INTERVAL)
+                    ) AS foo
+                                UNION ALL
+            SELECT  cp.id
+			   FROM $cp cp 
+                    LEFT JOIN $setting setting
+                        ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
+                    LEFT JOIN $circ circ ON (circ.target_copy = cp.id AND circ.id IS NULL)
+              WHERE cp.status = 7
+                    AND cp.create_date < NOW() - CAST( COALESCE( BTRIM( setting.value,'"' ), ? )  AS INTERVAL)
+          )
 	SQL
 
 	my $sth = action::circulation->db_Main->prepare_cached($sql);



More information about the open-ils-commits mailing list