From 2b3524891b8fb98df75b160c9cf6e8ffc148e311 Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Wed, 5 Nov 2014 09:05:56 -0500 Subject: [PATCH] Adding scripts I created to process longoverdue circs and notices. --- longoverdue/batch_process_longoverdue.sh | 20 ++++++++++++++++++++ longoverdue/batch_process_longoverdue_notices.sh | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 longoverdue/batch_process_longoverdue.sh create mode 100644 longoverdue/batch_process_longoverdue_notices.sh diff --git a/longoverdue/batch_process_longoverdue.sh b/longoverdue/batch_process_longoverdue.sh new file mode 100644 index 0000000..343fa7b --- /dev/null +++ b/longoverdue/batch_process_longoverdue.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# script used to batch process longoverdue circs between 3 years and 6 months old. +# it updates the action_trigger.event_definition for marking items longoverdue, then +# runs the process, looping until $DELAY reaches 6 months. + +DELAY=35 +MAX_DELAY=36 +PSQL="/usr/bin/psql" +PSQL_USER="evergreen" +DB_HOST="db01" + +while [ "$DELAY" -ge 6 ]; do + echo "`date`: Entering $DELAY months as delay and $MAX_DELAY months as max delay" + $PSQL -U $PSQL_USER -h $DB_HOST -c "UPDATE action_trigger.event_definition SET delay = '$DELAY months'::interval, max_delay = '$MAX_DELAY months'::interval WHERE id = 49;" + . /etc/profile && /openils/bin/action_trigger_runner.pl --osrf-config /openils/conf/opensrf_core.xml --process-hooks --run-pending --granularity longoverdue --granularity-only + DELAY=$[$DELAY-1] + MAX_DELAY=$[$MAX_DELAY-1] +done + diff --git a/longoverdue/batch_process_longoverdue_notices.sh b/longoverdue/batch_process_longoverdue_notices.sh new file mode 100644 index 0000000..77dfe49 --- /dev/null +++ b/longoverdue/batch_process_longoverdue_notices.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# a script to churn through processing longoverdue notices. In this +# case, the A/T process was choking because we were trying to process +# too large a chunk of notices. We decided that 3,000 at a time was +# a good size to loop through. + +COUNT=`psql -U evergreen -h db02 -A -t -c "select count(*) from action_trigger.event where state = 'collected' and event_def = 50"` + +while [ "$COUNT" -gt "0" ]; do + echo "Begin loop at `date`. Count is $COUNT." + psql -U evergreen -h db01 -c "update action_trigger.event set start_time = null, update_time = null, update_process = null, state = 'pending', template_output = null where id in (select id from action_trigger.event where event_def = 50 and state = 'collected' limit 3000)" + time /openils/bin/action_trigger_runner.pl --osrf-config /openils/conf/opensrf_core.xml --verbose --run-pending --granularity longoverdue-notices --granularity-only + COUNT=`psql -U evergreen -h db02 -A -t -c "select count(*) from action_trigger.event where state = 'collected' and event_def = 50"` + echo "End loop at `date`. Count is now $COUNT." +done -- 2.11.0