Purge Circulations: Allow global age as forced min
authorThomas Berezansky <tsbere@mvlc.org>
Mon, 18 Jun 2012 17:29:58 +0000 (13:29 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Fri, 1 Feb 2013 14:54:35 +0000 (09:54 -0500)
This allows a library to keep all circs in the last Y interval, regardless
of user settings that may otherwise cause an earlier purging.

Another global flag that defaults to off controls this behavior.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql

index 30282b1..0f21762 100644 (file)
@@ -770,6 +770,7 @@ DECLARE
     usr_keep_start  actor.usr_setting%ROWTYPE;
     org_keep_age    INTERVAL;
     org_use_last    BOOL = false;
+    org_age_is_min  BOOL = false;
     org_keep_count  INT;
 
     keep_age        INTERVAL;
@@ -794,6 +795,7 @@ BEGIN
     END IF;
 
     SELECT enabled INTO org_use_last FROM config.global_flag WHERE name = 'history.circ.retention_uses_last_finished';
+    SELECT enabled INTO org_age_is_min FROM config.global_flag WHERE name = 'history.circ.retention_age_is_min';
 
     -- First, find copies with more than keep_count non-renewal circs
     FOR target_acp IN
@@ -843,7 +845,11 @@ BEGIN
             ELSIF usr_keep_start.value IS NOT NULL THEN
                 keep_age := AGE(NOW(), oils_json_to_text(usr_keep_start.value)::TIMESTAMPTZ);
             ELSE
-                keep_age := COALESCE( org_keep_age::INTERVAL, '2000 years'::INTERVAL );
+                keep_age := COALESCE( org_keep_age, '2000 years'::INTERVAL );
+            END IF;
+
+            IF org_age_is_min THEN
+                keep_age := GREATEST( keep_age, org_keep_age );
             END IF;
 
             CONTINUE WHEN AGE(NOW(), last_finished) < keep_age;
index a76dd74..050df6d 100644 (file)
@@ -8991,6 +8991,14 @@ INSERT INTO config.global_flag (name, label)
             'cgf',
             'label'
         )
+    ),(
+        'history.circ.retention_age_is_min',
+        oils_i18n_gettext(
+            'history.circ.retention_age_is_min',
+            'Historical Circulations are kept for global retention age at a minimum, regardless of user preferences.',
+            'cgf',
+            'label'
+        )
     );
 
 INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)