# Run the reshelving completer
2 0 * * * . ~/.bashrc && $EG_BIN_DIR/reshelving_complete.srfsh
+# Run the pending user purger
+2 30 * * * . ~/.bashrc && $EG_BIN_DIR/purge_pending_users.srfsh
+
# create the list of blocked patrons for offline use
# Note: The resulting list.txt file needs to be copied to all Apache servers
30 6 * * * . ~/.bashrc && $EG_BIN_DIR/offline-blocked-list.pl $SRF_CORE > $OPENILS/var/web/standalone/list.txt
complete BOOL DEFAULT FALSE
);
+-- stored procedure for deleting expired pending patrons
+CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$
+DECLARE
+ org_id INT;
+ intvl TEXT;
+BEGIN
+ FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP
+
+ SELECT INTO intvl value FROM
+ actor.org_unit_ancestor_setting(
+ 'opac.pending_user_expire_interval', org_id);
+
+ CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null';
+
+ -- de-JSON-ify the string
+ SELECT INTO intvl TRIM(BOTH '"' FROM intvl);
+
+ DELETE FROM staging.user_stage
+ WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW();
+
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
COMMIT;
ALTER COLUMN state DROP DEFAULT,
ALTER COLUMN state DROP NOT NULL;
+-- stored procedure for deleting expired pending patrons
+CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$
+DECLARE
+ org_id INT;
+ intvl TEXT;
+BEGIN
+ FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP
+
+ SELECT INTO intvl value FROM
+ actor.org_unit_ancestor_setting(
+ 'opac.pending_user_expire_interval', org_id);
+
+ CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null';
+
+ -- de-JSON-ify the string
+ SELECT INTO intvl TRIM(BOTH '"' FROM intvl);
+
+ DELETE FROM staging.user_stage
+ WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW();
+
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
+
+
INSERT INTO config.org_unit_setting_type
(name, grp, datatype, label, description)
VALUES (
--- /dev/null
+#!/openils/bin/srfsh
+open open-ils.cstore
+request open-ils.cstore open-ils.cstore.transaction.begin
+request open-ils.cstore open-ils.cstore.json_query {"from":["staging.purge_pending_users"]}
+request open-ils.cstore open-ils.cstore.transaction.commit
+close open-ils.cstore
+