From 9dbeff34b23a833fd2cb78702cace06680d0f941 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 21 Jan 2015 16:36:42 -0500 Subject: [PATCH] JBAS-315 circ anon script supports configurable windows Allow the anonymizer to process arbitrarily large windows of circulations based on their xact_finish date. This makes it faster to re-process old circs to accommodate changes in user settings which makes older circs eligible for anonymization. Signed-off-by: Bill Erickson --- KCLS/utility-scripts/purge_circs/purge_circulations.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/KCLS/utility-scripts/purge_circs/purge_circulations.sh b/KCLS/utility-scripts/purge_circs/purge_circulations.sh index 13e1306c81..3ed8186700 100644 --- a/KCLS/utility-scripts/purge_circs/purge_circulations.sh +++ b/KCLS/utility-scripts/purge_circs/purge_circulations.sh @@ -5,6 +5,7 @@ USAGE="thisscript.sh --start --duration DATE_START="" #action.circulation.xact_finish date to start with; passed as a parameter to psql MAX_DURATION_MINUTES="" #Do not call psql again after this many minutes MAX_DATE="" # if set, do not process circs whose action.circulation.xact_finish exceeds this date +INCREMENT="1 day" while [ $# -gt 0 ] ; do case $1 in --start) DATE_START="$2" @@ -16,6 +17,9 @@ while [ $# -gt 0 ] ; do --end) MAX_DATE="$2" shift ;; + --increment) INCREMENT="$2" + shift + ;; *) shift ;; esac @@ -46,7 +50,7 @@ echo "This script will stop after $(date --date=@$EPOCH_STOP)." EPOCH_NOW=$EPOCH_START function day_increment { - DAY_TO_INCREMENT=$(date --date="$DAY_TO_INCREMENT + 1 day" '+%Y-%m-%d') + DAY_TO_INCREMENT=$(date --date="$DAY_TO_INCREMENT + $INCREMENT" '+%Y-%m-%d') }; while [[ $EPOCH_NOW -lt $EPOCH_STOP ]] ; do @@ -54,9 +58,11 @@ while [[ $EPOCH_NOW -lt $EPOCH_STOP ]] ; do DAY_TO_INCREMENT=$DATE_START day_increment DATE_END=$DAY_TO_INCREMENT - if [ -n "$MAX_DATE" -a $DATE_START \> $MAX_DATE ]; then - echo "Reached max date of $MAX_DATE; exiting" - break; + if [ -n "$MAX_DATE" -a $DATE_END \> $MAX_DATE ]; then + echo "Reached max date of $MAX_DATE; truncating END_DATE" + END_DATE=$MAX_DATE + # tell the script to stop after this pass + EPOCH_STOP=$(date '+%s') fi; echo "Beginning $DATE_START -- $DATE_END ..." psql -U evergreen --file=purge_circulations.psql --quiet --variable=ts_start="'$DATE_START'" --variable=ts_end="'$DATE_END'" @@ -65,3 +71,4 @@ while [[ $EPOCH_NOW -lt $EPOCH_STOP ]] ; do DATE_START=$DAY_TO_INCREMENT EPOCH_NOW=$(date '+%s') done + -- 2.11.0