[open-ils-commits] [GIT] Evergreen ILS branch master updated. 95ea3d5223963777f8d76d11ab0dd7e4eeeeceff
Evergreen Git
git at git.evergreen-ils.org
Wed Aug 24 12:40:36 EDT 2016
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, master has been updated
via 95ea3d5223963777f8d76d11ab0dd7e4eeeeceff (commit)
via cfad22b42c2b3bbe04697a31644c925eff8e6a1a (commit)
via fc5b3ec873215363be00ca4ff51ccd4a42403280 (commit)
via ea8b2ae34dee14d15f4958ced3dadbdc4ea8ebbe (commit)
via b1f4d599b87a375ab43b7439dcc2ba1208c7c5be (commit)
from 40e20683c5d2aa78a128ed019be163349545a4d7 (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 95ea3d5223963777f8d76d11ab0dd7e4eeeeceff
Author: Mike Rylander <mrylander at gmail.com>
Date: Wed Aug 24 12:38:58 2016 -0400
Stamping upgrade script for transient usr_activity
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 0bba11c..d7438fb 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0992', :eg_version); -- berick/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0993', :eg_version); -- berick/miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql b/Open-ILS/src/sql/Pg/upgrade/0993.schema.usr_activity_transient.sql
similarity index 94%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
rename to Open-ILS/src/sql/Pg/upgrade/0993.schema.usr_activity_transient.sql
index fb70a87..d195004 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0993.schema.usr_activity_transient.sql
@@ -1,7 +1,7 @@
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0993', :eg_version);
ALTER TABLE config.usr_activity_type
ALTER COLUMN transient SET DEFAULT TRUE;
commit cfad22b42c2b3bbe04697a31644c925eff8e6a1a
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Apr 15 17:07:02 2016 -0400
LP#1570909 User activity purge release notes
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/docs/RELEASE_NOTES_NEXT/Administration/user-activity-purge.adoc b/docs/RELEASE_NOTES_NEXT/Administration/user-activity-purge.adoc
new file mode 100644
index 0000000..03522cb
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/Administration/user-activity-purge.adoc
@@ -0,0 +1,29 @@
+Purge User Activity
+^^^^^^^^^^^^^^^^^^^
+
+User activity types are now set to transient by default for new
+Evergreen installs.. This means only the most recent activity entry per
+user per activity type is retained in the database.
+
+This change does not affect existing activity types, which were set to
+non-transient by default. To make an activity type transient, modify the
+'Transient' field of the desired type in the staff client under Admin ->
+Server Administration -> User Activity Types.
+
+Setting an activity type to transient means data for a given user will
+be cleaned up automatically if and when the user performs the activity
+in question. However, administrators can also force an activity
+cleanup via SQL. This is useful for ensuring that all old activity
+data is deleted and for controlling when the cleanup occurs, which
+may be useulf on very large actor.usr_activity tables.
+
+To force clean all activity types:
+
+[source,sql]
+------------------------------------------------------------
+SELECT actor.purge_usr_activity_by_type(etype.id)
+ FROM config.usr_activity_type etype;
+------------------------------------------------------------
+
+NOTE: This could take hours to run on a very large actor.usr_activity table.
+
commit fc5b3ec873215363be00ca4ff51ccd4a42403280
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Apr 15 16:54:48 2016 -0400
LP#1570909 User activity purge pgtap test
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/live_t/purge-user-activity.pg b/Open-ILS/src/sql/Pg/live_t/purge-user-activity.pg
new file mode 100644
index 0000000..bf38146
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/live_t/purge-user-activity.pg
@@ -0,0 +1,68 @@
+BEGIN;
+
+SELECT plan(6);
+
+\set usr_one 1
+\set usr_two 2
+
+-- shuffle event_times for randomness.
+INSERT INTO actor.usr_activity (usr, etype, event_time) VALUES
+ (:usr_one, 1, NOW() - '2 days'::INTERVAL),
+ (:usr_one, 1, NOW()),
+ (:usr_one, 1, NOW() - '1 days'::INTERVAL),
+ (:usr_one, 2, NOW() - '1 days'::INTERVAL),
+ (:usr_one, 2, NOW()),
+ (:usr_one, 2, NOW() - '2 days'::INTERVAL),
+ (:usr_two, 1, NOW() - '1 days'::INTERVAL),
+ (:usr_two, 1, NOW()),
+ (:usr_two, 1, NOW() - '2 days'::INTERVAL);
+
+
+SELECT actor.purge_usr_activity_by_type(1);
+SELECT actor.purge_usr_activity_by_type(2);
+
+SELECT is(
+ (SELECT COUNT(*) FROM actor.usr_activity
+ WHERE usr = :usr_one AND etype = 1),
+ 1::BIGINT,
+ 'Confirm only one event row exists'
+);
+
+SELECT is(
+ (SELECT DATE(event_time) FROM actor.usr_activity
+ WHERE usr = :usr_one AND etype = 1),
+ DATE(NOW()),
+ 'Confirm most recent event is retained'
+);
+
+SELECT is(
+ (SELECT COUNT(*) FROM actor.usr_activity
+ WHERE usr = :usr_one AND etype = 2),
+ 1::BIGINT,
+ 'Confirm only one event row exists'
+);
+
+SELECT is(
+ (SELECT DATE(event_time) FROM actor.usr_activity
+ WHERE usr = :usr_one AND etype = 2),
+ DATE(NOW()),
+ 'Confirm most recent event is retained'
+);
+
+SELECT is(
+ (SELECT COUNT(*) FROM actor.usr_activity
+ WHERE usr = :usr_two AND etype = 1),
+ 1::BIGINT,
+ 'Confirm only one event row exists'
+);
+
+SELECT is(
+ (SELECT DATE(event_time) FROM actor.usr_activity
+ WHERE usr = :usr_two AND etype = 1),
+ DATE(NOW()),
+ 'Confirm most recent event is retained'
+);
+
+SELECT * FROM finish();
+ROLLBACK;
+
commit ea8b2ae34dee14d15f4958ced3dadbdc4ea8ebbe
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Apr 15 16:26:57 2016 -0400
LP#1570909 User activity purge function
Utility function for removing all activity entries by activity type,
except for the most recent entry per user. This is primarily useful
when cleaning up rows prior to setting the transient flag on an
activity type to true. It allows for immediate cleanup of data (e.g.
for patron privacy) and lets admins control when the data is deleted,
which could be useful for huge activity tables.
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
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 6feebdd..0bba11c 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -1011,6 +1011,26 @@ CREATE TABLE config.usr_activity_type (
CONSTRAINT one_of_wwh CHECK (COALESCE(ewho,ewhat,ehow) IS NOT NULL)
);
+-- Remove all activity entries by activity type,
+-- except the most recent entry per user.
+CREATE OR REPLACE FUNCTION
+ actor.purge_usr_activity_by_type(act_type INTEGER)
+ RETURNS VOID AS $$
+DECLARE
+ cur_usr INTEGER;
+BEGIN
+ FOR cur_usr IN SELECT DISTINCT(usr)
+ FROM actor.usr_activity WHERE etype = act_type LOOP
+ DELETE FROM actor.usr_activity WHERE id IN (
+ SELECT id
+ FROM actor.usr_activity
+ WHERE usr = cur_usr AND etype = act_type
+ ORDER BY event_time DESC OFFSET 1
+ );
+
+ END LOOP;
+END $$ LANGUAGE PLPGSQL;
+
CREATE UNIQUE INDEX unique_wwh ON config.usr_activity_type
(COALESCE(ewho,''), COALESCE (ewhat,''), COALESCE(ehow,''));
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
index 02d4a8b..fb70a87 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
@@ -6,5 +6,30 @@ SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
ALTER TABLE config.usr_activity_type
ALTER COLUMN transient SET DEFAULT TRUE;
+-- Utility function for removing all activity entries by activity type,
+-- except for the most recent entry per user. This is primarily useful
+-- when cleaning up rows prior to setting the transient flag on an
+-- activity type to true. It allows for immediate cleanup of data (e.g.
+-- for patron privacy) and lets admins control when the data is deleted,
+-- which could be useful for huge activity tables.
+
+CREATE OR REPLACE FUNCTION
+ actor.purge_usr_activity_by_type(act_type INTEGER)
+ RETURNS VOID AS $$
+DECLARE
+ cur_usr INTEGER;
+BEGIN
+ FOR cur_usr IN SELECT DISTINCT(usr)
+ FROM actor.usr_activity WHERE etype = act_type LOOP
+ DELETE FROM actor.usr_activity WHERE id IN (
+ SELECT id
+ FROM actor.usr_activity
+ WHERE usr = cur_usr AND etype = act_type
+ ORDER BY event_time DESC OFFSET 1
+ );
+
+ END LOOP;
+END $$ LANGUAGE PLPGSQL;
+
COMMIT;
commit b1f4d599b87a375ab43b7439dcc2ba1208c7c5be
Author: Bill Erickson <berickxx at gmail.com>
Date: Fri Apr 15 11:23:33 2016 -0400
LP#1570909 User activity transient default
Only retain the most recent user activity entry (per activity type) by
default.
Signed-off-by: Bill Erickson <berickxx at gmail.com>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
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 0c8e9ad..6feebdd 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -1007,7 +1007,7 @@ CREATE TABLE config.usr_activity_type (
label TEXT NOT NULL, -- i18n
egroup config.usr_activity_group NOT NULL,
enabled BOOL NOT NULL DEFAULT TRUE,
- transient BOOL NOT NULL DEFAULT FALSE,
+ transient BOOL NOT NULL DEFAULT TRUE,
CONSTRAINT one_of_wwh CHECK (COALESCE(ewho,ewhat,ehow) IS NOT NULL)
);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
new file mode 100644
index 0000000..02d4a8b
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.usr_activity_transient.sql
@@ -0,0 +1,10 @@
+
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE config.usr_activity_type
+ ALTER COLUMN transient SET DEFAULT TRUE;
+
+COMMIT;
+
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 24 ++++++-
Open-ILS/src/sql/Pg/live_t/purge-user-activity.pg | 68 ++++++++++++++++++++
.../upgrade/0993.schema.usr_activity_transient.sql | 35 ++++++++++
.../Administration/user-activity-purge.adoc | 29 ++++++++
4 files changed, 154 insertions(+), 2 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/live_t/purge-user-activity.pg
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0993.schema.usr_activity_transient.sql
create mode 100644 docs/RELEASE_NOTES_NEXT/Administration/user-activity-purge.adoc
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list