From: Bill Erickson Date: Wed, 29 Jul 2015 21:51:58 +0000 (-0400) Subject: JBAS-827 Move juv/adult and envisionware updates to utility X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8cc69960d92f13ea7b5cc75c541d52245a592ea3;p=working%2FEvergreen.git JBAS-827 Move juv/adult and envisionware updates to utility Make utility-server friendly versions of the juv_to_adult and envisionware access batch SQL scripts. Signed-off-by: Bill Erickson --- diff --git a/KCLS/utility-scripts/CRONTAB b/KCLS/utility-scripts/CRONTAB index b4626ca02f..4f4abef7f7 100644 --- a/KCLS/utility-scripts/CRONTAB +++ b/KCLS/utility-scripts/CRONTAB @@ -95,6 +95,12 @@ PGHOST = localhost # change for cluster install # Update copy status for BC #0 22 * * * cd $SCRIPT_DIR/bc_missing/ && ./bc_missing.sh +# Update Envisionware patron access +#30 0 * * * cd $SCRIPT_DIR/envware_access/ && ./envware_access.sh + +# Update Envisionware patron access +#0 1 * * * cd $SCRIPT_DIR/juv_to_adult/ && ./juv_to_adult.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 # to run (~45 minutes). The first range starts at 2004-08-12, which is the diff --git a/KCLS/utility-scripts/envware_access/envware_access.sh b/KCLS/utility-scripts/envware_access/envware_access.sh new file mode 100755 index 0000000000..405ea3f6da --- /dev/null +++ b/KCLS/utility-scripts/envware_access/envware_access.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -eu + +echo -n "Updating Envisionware access at "; +date +"%F %T" + +psql -U evergreen -f envware_access.sql + +echo -n "Completed updating Envisionware access at " +date +"%F %T" diff --git a/KCLS/utility-scripts/envware_access/envware_access.sql b/KCLS/utility-scripts/envware_access/envware_access.sql new file mode 100644 index 0000000000..1f9338792d --- /dev/null +++ b/KCLS/utility-scripts/envware_access/envware_access.sql @@ -0,0 +1,38 @@ +-- Run these two commands prior to invoking this script: +-- CREATE SCHEMA envisionware; +-- +-- CREATE TABLE envisionware.users_made_no_access ( +-- id INTEGER, +-- original_net_access_level INTEGER, +-- date_changed TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() +-- ); + +BEGIN; + +SET statement_timeout = 0; + +CREATE TEMP TABLE temp_users ( + id INTEGER PRIMARY KEY, + original_net_access_level INTEGER +); + +INSERT INTO temp_users (id,original_net_access_level) + SELECT id, net_access_level FROM actor.usr WHERE + (active = false OR expire_date < NOW()) + AND net_access_level <> 101; -- 4 in test, 101 in prod + +INSERT INTO envisionware.users_made_no_access(id,original_net_access_level) + SELECT * FROM temp_users; + +INSERT INTO actor.usr_standing_penalty (usr,standing_penalty,org_unit,note) + SELECT + u.id, + 21, -- SILENT_NOTE + 1, -- or u.home_ou + 'Original filter prior to Envisionware rollover: ' || name + FROM temp_users u, config.net_access_level c + WHERE original_net_access_level = c.id; + +UPDATE actor.usr u SET net_access_level = 101 FROM temp_users t WHERE u.id = t.id; -- 4 in test, 101 in prod +UPDATE actor.usr u SET profile = 16 FROM temp_users t WHERE u.id = t.id; +COMMIT; diff --git a/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sh b/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sh new file mode 100755 index 0000000000..56964e58f8 --- /dev/null +++ b/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eu + +echo -n "Updating patron juvenile flag at "; +date +"%F %T" + +psql -U evergreen -f juv_to_adult.sql + +echo -n "Completed updating patron juvenile flag at " +date +"%F %T" + + diff --git a/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sql b/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sql new file mode 100644 index 0000000000..7a4f8fcae2 --- /dev/null +++ b/KCLS/utility-scripts/juv_to_adult/juv_to_adult.sql @@ -0,0 +1,10 @@ +-- query is more selective than that currently used by +-- the open-ils.storage.actor.user.juvenile_to_adult method +-- ESI/Galen Charlton 2012-07-13 +-- TODO: add 'NOT deleted' to open-ils.storage method. +-- so we won't need this custom script. +SET statement_timeout = 0; + +UPDATE actor.usr SET juvenile = FALSE + WHERE AGE(dob) > '18 years' AND juvenile AND NOT deleted; +