[open-ils-commits] r14786 - tags/rel_1_6_0_0/Open-ILS/src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Nov 5 13:28:19 EST 2009
Author: miker
Date: 2009-11-05 13:28:15 -0500 (Thu, 05 Nov 2009)
New Revision: 14786
Modified:
tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/090.schema.action.sql
tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql
Log:
use a trigger to push day-granular circ due_date to the end of the calendar day
Modified: tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/090.schema.action.sql
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-11-05 18:14:13 UTC (rev 14785)
+++ tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/090.schema.action.sql 2009-11-05 18:28:15 UTC (rev 14786)
@@ -130,7 +130,18 @@
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
+CREATE OR REPLACE FUNCTION action.push_circ_due_time () RETURNS TRIGGER AS $$
+BEGIN
+ IF (EXTRACT(EPOCH FROM NEW.circ_duration)::INT % EXTRACT(EPOCH FROM '1 day'::INTERVAL)::INT) = 0 THEN
+ NEW.due_date = (NEW.due_date::DATE + '1 day'::INTERVAL - '1 second'::INTERVAL)TIMESTAMPTZ;
+ END IF;
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER push_due_date_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.push_circ_due_time();
+
CREATE TABLE action.aged_circulation (
usr_post_code TEXT,
usr_home_ou INT NOT NULL,
Modified: tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql
===================================================================
--- tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql 2009-11-05 18:14:13 UTC (rev 14785)
+++ tags/rel_1_6_0_0/Open-ILS/src/sql/Pg/1.4.0.5-1.6.0.0-upgrade-db.sql 2009-11-05 18:28:15 UTC (rev 14786)
@@ -1100,6 +1100,18 @@
CREATE TRIGGER mat_summary_change_tgr AFTER UPDATE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_update ();
CREATE TRIGGER mat_summary_remove_tgr AFTER DELETE ON action.circulation FOR EACH ROW EXECUTE PROCEDURE money.mat_summary_delete ();
+CREATE OR REPLACE FUNCTION action.push_circ_due_time () RETURNS TRIGGER AS $$
+BEGIN
+ IF (EXTRACT(EPOCH FROM NEW.circ_duration)::INT % EXTRACT(EPOCH FROM '1 day'::INTERVAL)::INT) = 0 THEN
+ NEW.due_date = (NEW.due_date::DATE + '1 day'::INTERVAL - '1 second'::INTERVAL)TIMESTAMPTZ;
+ END IF;
+
+ RETURN NEW;
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER push_due_date_tgr BEFORE INSERT ON action.circulation FOR EACH ROW EXECUTE PROCEDURE action.push_circ_due_time();
+
CREATE OR REPLACE VIEW action.billable_circulations AS
SELECT *
FROM action.circulation
More information about the open-ils-commits
mailing list