[open-ils-commits] [GIT] Evergreen ILS branch rel_2_1 updated. d33a3bf9de35b7363798dfdc021ca6fb4a11ba53
Evergreen Git
git at git.evergreen-ils.org
Thu Aug 4 14:42:16 EDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, rel_2_1 has been updated
via d33a3bf9de35b7363798dfdc021ca6fb4a11ba53 (commit)
via 25604d266001635b33168d1d5f39d70dc0ff93c0 (commit)
from cf189962ce5c80df28031f638c982cba0e39494d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d33a3bf9de35b7363798dfdc021ca6fb4a11ba53
Author: Mike Rylander <mrylander at gmail.com>
Date: Thu Aug 4 14:38:17 2011 -0400
Stamped upgrade script for schema.circ_holds_history_repairs
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 05d7ca0..4774c26 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -57,7 +57,7 @@ CREATE TABLE config.upgrade_log (
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0590'); -- tsbere/miker
+INSERT INTO config.upgrade_log (version) VALUES ('0591'); -- berick/miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql b/Open-ILS/src/sql/Pg/upgrade/0591.schema.circ_holds_history_repairs.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql
rename to Open-ILS/src/sql/Pg/upgrade/0591.schema.circ_holds_history_repairs.sql
index ba663d2..f540f94 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0591.schema.circ_holds_history_repairs.sql
@@ -2,7 +2,7 @@
BEGIN;
-- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+INSERT INTO config.upgrade_log (version) VALUES ('0591'); -- berick/miker
CREATE OR REPLACE FUNCTION action.usr_visible_circs (usr_id INT) RETURNS SETOF action.circulation AS $func$
DECLARE
commit 25604d266001635b33168d1d5f39d70dc0ff93c0
Author: Bill Erickson <berick at esilibrary.com>
Date: Thu Aug 4 13:49:11 2011 -0400
Repair holds history func; sort circ history desc.
Update holds history to use oils_json_to_text instead of
oils_json_to_string, which does not exist.
Sort circ history newest to oldest by default.
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 44a3236..05c45ad 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -638,7 +638,7 @@ BEGIN
WHERE usr = usr_id
AND parent_circ IS NULL
AND xact_start > NOW() - view_age
- ORDER BY xact_start
+ ORDER BY xact_start DESC
LOOP
RETURN NEXT c;
END LOOP;
@@ -681,14 +681,14 @@ BEGIN
IF usr_view_age.value IS NOT NULL THEN
-- User opted in and supplied a retention age
- IF oils_json_to_string(usr_view_age.value)::INTERVAL > AGE(NOW(), oils_json_to_string(usr_view_start.value)::TIMESTAMPTZ) THEN
- view_age := AGE(NOW(), oils_json_to_string(usr_view_start.value)::TIMESTAMPTZ);
+ IF oils_json_to_text(usr_view_age.value)::INTERVAL > AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ) THEN
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
ELSE
- view_age := oils_json_to_string(usr_view_age.value)::INTERVAL;
+ view_age := oils_json_to_text(usr_view_age.value)::INTERVAL;
END IF;
ELSE
-- User opted in
- view_age := AGE(NOW(), oils_json_to_string(usr_view_start.value)::TIMESTAMPTZ);
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
END IF;
IF usr_view_count.value IS NOT NULL THEN
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql
new file mode 100644
index 0000000..ba663d2
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.circ_holds_history_repairs.sql
@@ -0,0 +1,110 @@
+-- Evergreen DB patch XXXX.schema.circ_holds_history_repairs.sql
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION action.usr_visible_circs (usr_id INT) RETURNS SETOF action.circulation AS $func$
+DECLARE
+ c action.circulation%ROWTYPE;
+ view_age INTERVAL;
+ usr_view_age actor.usr_setting%ROWTYPE;
+ usr_view_start actor.usr_setting%ROWTYPE;
+BEGIN
+ SELECT * INTO usr_view_age FROM actor.usr_setting WHERE usr = usr_id AND name = 'history.circ.retention_age';
+ SELECT * INTO usr_view_start FROM actor.usr_setting WHERE usr = usr_id AND name = 'history.circ.retention_start';
+
+ IF usr_view_age.value IS NOT NULL AND usr_view_start.value IS NOT NULL THEN
+ -- User opted in and supplied a retention age
+ IF oils_json_to_text(usr_view_age.value)::INTERVAL > AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ) THEN
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
+ ELSE
+ view_age := oils_json_to_text(usr_view_age.value)::INTERVAL;
+ END IF;
+ ELSIF usr_view_start.value IS NOT NULL THEN
+ -- User opted in
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
+ ELSE
+ -- User did not opt in
+ RETURN;
+ END IF;
+
+ FOR c IN
+ SELECT *
+ FROM action.circulation
+ WHERE usr = usr_id
+ AND parent_circ IS NULL
+ AND xact_start > NOW() - view_age
+ ORDER BY xact_start DESC
+ LOOP
+ RETURN NEXT c;
+ END LOOP;
+
+ RETURN;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION action.usr_visible_holds (usr_id INT) RETURNS SETOF action.hold_request AS $func$
+DECLARE
+ h action.hold_request%ROWTYPE;
+ view_age INTERVAL;
+ view_count INT;
+ usr_view_count actor.usr_setting%ROWTYPE;
+ usr_view_age actor.usr_setting%ROWTYPE;
+ usr_view_start actor.usr_setting%ROWTYPE;
+BEGIN
+ SELECT * INTO usr_view_count FROM actor.usr_setting WHERE usr = usr_id AND name = 'history.hold.retention_count';
+ SELECT * INTO usr_view_age FROM actor.usr_setting WHERE usr = usr_id AND name = 'history.hold.retention_age';
+ SELECT * INTO usr_view_start FROM actor.usr_setting WHERE usr = usr_id AND name = 'history.hold.retention_start';
+
+ FOR h IN
+ SELECT *
+ FROM action.hold_request
+ WHERE usr = usr_id
+ AND fulfillment_time IS NULL
+ AND cancel_time IS NULL
+ ORDER BY request_time DESC
+ LOOP
+ RETURN NEXT h;
+ END LOOP;
+
+ IF usr_view_start.value IS NULL THEN
+ RETURN;
+ END IF;
+
+ IF usr_view_age.value IS NOT NULL THEN
+ -- User opted in and supplied a retention age
+ IF oils_json_to_text(usr_view_age.value)::INTERVAL > AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ) THEN
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
+ ELSE
+ view_age := oils_json_to_text(usr_view_age.value)::INTERVAL;
+ END IF;
+ ELSE
+ -- User opted in
+ view_age := AGE(NOW(), oils_json_to_text(usr_view_start.value)::TIMESTAMPTZ);
+ END IF;
+
+ IF usr_view_count.value IS NOT NULL THEN
+ view_count := oils_json_to_text(usr_view_count.value)::INT;
+ ELSE
+ view_count := 1000;
+ END IF;
+
+ -- show some fulfilled/canceled holds
+ FOR h IN
+ SELECT *
+ FROM action.hold_request
+ WHERE usr = usr_id
+ AND ( fulfillment_time IS NOT NULL OR cancel_time IS NOT NULL )
+ AND request_time > NOW() - view_age
+ ORDER BY request_time DESC
+ LIMIT view_count
+ LOOP
+ RETURN NEXT h;
+ END LOOP;
+
+ RETURN;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/090.schema.action.sql | 10 ++--
... => 0591.schema.circ_holds_history_repairs.sql} | 54 ++++++++++---------
3 files changed, 34 insertions(+), 32 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0283.schema.user-visiable-holds-circs-fixes.sql => 0591.schema.circ_holds_history_repairs.sql} (72%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list