From 390cd0b2135c9ec4abeba195c04612d77ee968b3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 29 Jul 2015 16:51:48 -0400 Subject: [PATCH] JBAS-827 BC missing copy update re-org * Move the BC copy update script into the utility scripts * Update copy 'floating' column semantics for EG 2.5 Signed-off-by: Bill Erickson --- KCLS/utility-scripts/CRONTAB | 2 + KCLS/utility-scripts/bc_missing/bc_missing.sh | 10 ++++ KCLS/utility-scripts/bc_missing/bc_missing.sql | 71 ++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100755 KCLS/utility-scripts/bc_missing/bc_missing.sh create mode 100644 KCLS/utility-scripts/bc_missing/bc_missing.sql diff --git a/KCLS/utility-scripts/CRONTAB b/KCLS/utility-scripts/CRONTAB index 846c0ce125..b4626ca02f 100644 --- a/KCLS/utility-scripts/CRONTAB +++ b/KCLS/utility-scripts/CRONTAB @@ -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 index 0000000000..14e5ab3ef8 --- /dev/null +++ b/KCLS/utility-scripts/bc_missing/bc_missing.sh @@ -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 index 0000000000..14a31f09f5 --- /dev/null +++ b/KCLS/utility-scripts/bc_missing/bc_missing.sql @@ -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 + ); + + -- 2.11.0