JBAS-827 BC missing copy update re-org
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Jul 2015 20:51:48 +0000 (16:51 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
* Move the BC copy update script into the utility scripts
* Update copy 'floating' column semantics for EG 2.5

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/CRONTAB
KCLS/utility-scripts/bc_missing/bc_missing.sh [new file with mode: 0755]
KCLS/utility-scripts/bc_missing/bc_missing.sql [new file with mode: 0644]

index 846c0ce..b4626ca 100644 (file)
@@ -92,6 +92,8 @@ PGHOST     = localhost # change for cluster install
 #10 2 * * * find /var/log/evergreen -type f -ctime +60 -delete
 #30 2 * * * find /var/log/evergreen -type f -ctime +2 -exec gzip {} \;
 
+# Update copy status for BC
+#0 22 * * * cd $SCRIPT_DIR/bc_missing/ && ./bc_missing.sh
 
 # Anonymize a range of historical circs each night, with a maximum run
 # time of 120 minutes.  We split them up, because each range takes time
diff --git a/KCLS/utility-scripts/bc_missing/bc_missing.sh b/KCLS/utility-scripts/bc_missing/bc_missing.sh
new file mode 100755 (executable)
index 0000000..14e5ab3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -eu
+
+echo -n "Updating copy visibility for BC at "
+date +"%F %T" 
+
+psql -U evergreen -f bc_missing.sql
+
+echo -n "Completed updating copy visbility for BC at "
+date +"%F %T" 
diff --git a/KCLS/utility-scripts/bc_missing/bc_missing.sql b/KCLS/utility-scripts/bc_missing/bc_missing.sql
new file mode 100644 (file)
index 0000000..14a31f0
--- /dev/null
@@ -0,0 +1,71 @@
+-- https://redmine.commandprompt.com/issues/35179
+
+SET statement_timeout = 0;
+
+-- hiding by status
+
+UPDATE asset.copy
+    SET (edit_date, opac_visible) = (now(), 'f')
+    WHERE id IN (
+        SELECT asset.copy.id
+        FROM asset.copy
+        WHERE deleted = 'f'
+        AND opac_visible = 't'
+        AND status IN (
+            105, 121, 2, 106, 11, 101, 14, 13, 117, 104, 
+            115, 10, 3, 4, 120, 109, 118, 111, 103, 114
+        )
+    );
+
+-- hiding by location
+
+UPDATE asset.copy
+    SET (edit_date, opac_visible) = (now(), 'f')
+    WHERE id IN (
+        SELECT asset.copy.id
+        FROM asset.copy
+        INNER JOIN asset.copy_location
+            ON asset.copy.location = asset.copy_location.id
+        INNER JOIN config.i18n_core
+            ON cast(config.i18n_core.identity_value as integer) = asset.copy_location.id
+        WHERE asset.copy.deleted = 'f'
+        AND asset.copy.opac_visible = 't'
+        AND string IN (
+            'Equipment' , 'Adult Paperbacks' , 'Adult Toys/Games' ,
+            'Children''s Storytime' , 'Children''s Toys/Games' ,
+            'Children''s Materials' , 'Children''s Easy Materials' ,
+            'KidReach' , 'Tech Lab' , 'Storage' , 'Teen Materials' ,
+            'Generic' , 'Normandy Park' , 'Choice Reads'
+        )
+    );
+
+-- make the items that should be visible again as they become some
+-- kind of "available", but still following our business rules
+
+UPDATE asset.copy
+    SET (edit_date, opac_visible) = (now(), 't')
+    WHERE id IN (
+        SELECT DISTINCT asset.copy.id
+        FROM asset.copy
+        INNER JOIN asset.copy_location
+            ON asset.copy.location = asset.copy_location.id
+        INNER JOIN config.i18n_core
+            ON cast(config.i18n_core.identity_value as integer) = asset.copy_location.id
+        WHERE asset.copy.deleted = 'f'
+        AND asset.copy.opac_visible = 'f'
+        AND asset.copy.status IN ('0', '1', '6', '7', '8')
+        AND asset.copy.call_number <> '-1'
+        AND asset.copy.circ_modifier NOT IN (
+            '40', '41', '45', '46', '52', '1', '20', '23',
+            '24', '27', '33', '44', '56', '58', '66', '7')
+        AND asset.copy_location.opac_visible = 't'
+        AND string NOT IN (
+            'Equipment' , 'Adult Paperbacks' , 'Adult Toys/Games' ,
+            'Children''s Storytime' , 'Children''s Toys/Games' ,
+            'Children''s Materials' , 'Children''s Easy Materials' ,
+            'KidReach' , 'Tech Lab' , 'Storage' , 'Teen Materials' ,
+            'Generic' , 'Normandy Park' , 'Choice Reads' )
+        AND floating IS NULL
+    );
+
+