JBAS-1554 Circ history checker log cleanup
authorBill Erickson <berickxx@gmail.com>
Mon, 14 Aug 2017 18:03:08 +0000 (14:03 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Log each affected user once (instead of once per circ) for ease of
manual cleanup.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/tools/circ-history-migrate-check.sql

index dc7877d..c152bac 100644 (file)
@@ -22,6 +22,7 @@ DECLARE
     usr_count INTEGER DEFAULT 0;
     migrated_count INTEGER DEFAULT 0;
     pending_count INTEGER DEFAULT 0;
+    has_pending BOOLEAN;
 BEGIN
     FOR cur_usr IN 
         WITH history_users AS (
@@ -34,6 +35,7 @@ BEGIN
         ) SELECT users.id FROM history_users users ORDER BY users.id
     LOOP
         usr_count := usr_count + 1;
+        has_pending := FALSE;
         FOR cur_circ IN SELECT * FROM action.usr_visible_circs(cur_usr) LOOP
             PERFORM TRUE FROM action.usr_circ_history 
                 WHERE source_circ = cur_circ.id;
@@ -41,12 +43,16 @@ BEGIN
             IF FOUND THEN
                 migrated_count := migrated_count + 1;
             ELSE
-                RAISE NOTICE 'User % [offset = %] has pending circs', 
-                    cur_usr, (usr_count - 1);
+                has_pending := TRUE;
                 pending_count := pending_count + 1;
             END IF;
         END LOOP;
 
+        IF has_pending THEN
+            RAISE NOTICE 'User % [offset = %] has pending circs', 
+                cur_usr, (usr_count - 1);
+        END IF;
+
         IF (usr_count % 10000) = 0 THEN
             RAISE NOTICE 'Processed % patrons', usr_count;
             RAISE NOTICE 'Pending circs: %', pending_count;