# 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
--- /dev/null
+-- 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;
--- /dev/null
+-- 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;
+