[open-ils-commits] r575 - conifer/trunk/tools (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jul 9 16:41:48 EDT 2009


Author: dbs
Date: 2009-07-09 16:41:44 -0400 (Thu, 09 Jul 2009)
New Revision: 575

Modified:
   conifer/trunk/tools/end_of_the_day.pl
Log:
Expand the conditions where we set the due_time to 23:59:59.

Starting to wonder whether I should just change the edit due date function to set 23:59 instead...


Modified: conifer/trunk/tools/end_of_the_day.pl
===================================================================
--- conifer/trunk/tools/end_of_the_day.pl	2009-07-09 14:30:53 UTC (rev 574)
+++ conifer/trunk/tools/end_of_the_day.pl	2009-07-09 20:41:44 UTC (rev 575)
@@ -7,6 +7,13 @@
 # with an overdue charge at 48 hours + 5 minutes rather than at the end of the
 # day that 48 hours falls on.
 
+# We also found that editing the due date for a given item sets the corresponding
+# due time to 00:00 - which isn't great, as that means that it is due the minute
+# the day starts. So, for now, we'll set all daily / weekly loans or those loans
+# that are due exactly at midnight to being due at 23:59:59 - the very last second
+# of the day on which it is due. This probably meets our patrons' expectations a bit
+# better.
+
 use DBI;
 use Getopt::Long;
 use OpenSRF::EX qw/:try/;
@@ -43,34 +50,55 @@
 sub end_of_day {
 	my $set_due_time = shift;
 
-	my $select_stmt = <<STMT;
+        my $select_stmt = <<STMT;
 		SELECT id
 		FROM action.circulation
 		WHERE checkin_time IS NULL
-		AND due_date::TIME WITH TIME ZONE != '23:59:59-04'
-                AND duration_rule = '48_hours_2_renew'
-		AND circ_lib = 103
+		AND (
+			(
+				due_date::TIME != '23:59:59'
+				AND duration_rule LIKE ('%days%')
+				OR duration_rule LIKE ('%weeks%')
+				OR duration_rule = '48_hours_2_renew'
+			) OR (
+				due_date::TIME = '00:00:00'
+			)
+		) AND circ_lib IN (
+			SELECT id
+			FROM actor.org_unit
+			WHERE parent_ou = 105
+		)
 STMT
 
-	my $update_stmt = <<UPDATE;
-		UPDATE action.circulation
-		SET due_date = CAST(due_date::DATE || ' ' || '23:59:59-04' AS TIMESTAMP WITH TIME ZONE) 
+        my $update_stmt = <<UPDATE;
+                UPDATE action.circulation
+                SET due_date = CAST(due_date::DATE || ' ' || '23:59:59-04' AS TIMESTAMP WITH TIME ZONE)
 		WHERE checkin_time IS NULL
-		AND due_date::TIME WITH TIME ZONE != '23:59:59-04'
-		AND duration_rule = '48_hours_2_renew'
-		AND circ_lib = 103
-UPDATE
+		AND (
+			(
+				due_date::TIME != '23:59:59'
+				AND duration_rule LIKE ('%days%')
+				OR duration_rule LIKE ('%weeks%')
+				OR duration_rule = '48_hours_2_renew'
+			) OR (
+				due_date::TIME = '00:00:00'
+			)
+		) AND circ_lib IN (
+			SELECT id
+			FROM actor.org_unit
+			WHERE parent_ou = 105
+		)
+UPDATE  
 
 
-	my @results = $dbh->selectrow_array($select_stmt);
-	print localtime() . " - found " . scalar(@results) . " circulation transactions to update:\n";
-	foreach (@results) {
-		print "\t$_\n";
-	}
-	if ($set_due_time) {
-		my $stmt = $dbh->prepare($update_stmt);
-		my $updates = $stmt->execute();
-		print "Updated $updates circulation transactions.\n";
-	}
+        my $results = $dbh->selectcol_arrayref($select_stmt);
+        print localtime() . " - found " . scalar(@$results) . " circulation transactions to update:\n";
+        foreach (@$results) {
+                print "\t$_\n";
+        }
+        if ($set_due_time) {
+                my $stmt = $dbh->prepare($update_stmt);
+                my $updates = $stmt->execute();
+                print "Updated $updates circulation transactions.\n";
+        }
 }
-



More information about the open-ils-commits mailing list