Adding scripts I created to process longoverdue circs and notices.
authorChris Sharp <csharp@georgialibraries.org>
Wed, 5 Nov 2014 14:05:56 +0000 (09:05 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Wed, 5 Nov 2014 14:05:56 +0000 (09:05 -0500)
longoverdue/batch_process_longoverdue.sh [new file with mode: 0644]
longoverdue/batch_process_longoverdue_notices.sh [new file with mode: 0644]

diff --git a/longoverdue/batch_process_longoverdue.sh b/longoverdue/batch_process_longoverdue.sh
new file mode 100644 (file)
index 0000000..343fa7b
--- /dev/null
@@ -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 (file)
index 0000000..77dfe49
--- /dev/null
@@ -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