JBAS-1722 Automate backstage bib collisions processing
authorBill Erickson <berickxx@gmail.com>
Mon, 15 May 2017 15:32:38 +0000 (11:32 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Adds a separate command for processing bib collisions files.

./backstage-agent.sh -p <admin-pass> -c

Leaving as a separate command for now so that I can run it manually the
first time or two.  Will later integrate this into the quarterly results
processing task.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/authority-control/backstage/backstage-agent.sh

index 91037f3..029a97a 100755 (executable)
@@ -19,6 +19,11 @@ REPORTS_DIR_BASE="/openils/var/web/standalone/backstage"
 REPORTS_DIR=""
 WORKING_DIR=""
 
+# collisions file processing
+ADMIN_PASSWORD=""
+MERGE_PROFILE=104 # "Backstage Field Protection"
+BIB_QUEUE=5413 # "Backstage Quarterly" 
+
 SCRIPT_DIR=$PWD
 CURL="curl --silent --show-error --user $BACKSTAGE_USER:$BACKSTAGE_PASSWORD";
 
@@ -171,6 +176,43 @@ function bs_export_qtrly_bibs {
 }
 
 
+function bs_import_bib_collisions {
+    bs_set_qtr_dates;
+    bs_make_dirs "quarterly"
+    CFILE="$WORKING_DIR/bib-collisions.mrc";
+
+    echo "Processing bib collisions files $CFILE"
+
+    if [ ! -f "$CFILE" ]; then
+        echo "No bib collisions file to process."
+        return;
+    fi;
+
+    if [ ! -s "$CFILE" ]; then
+        echo "Bib collisions file is empty"
+        return;
+    fi;
+    
+    if [ ! -f "$WORKING_DIR/bib-collisions.bak.mrc" ]; then
+        echo "Making collisions file backup."
+        cp $CFILE "$WORKING_DIR/bib-collisions.bak.mrc";
+    else
+        echo "Collisions file backup already exists"
+    fi;
+
+    cd /openils/bin/
+    perl ./marc_stream_importer.pl      \
+        --spoolfile $CFILE              \
+        --user admin                    \
+        --password $ADMIN_PASSWORD      \
+        --bib-auto-overlay-exact        \
+        --bib-queue $BIB_QUEUE          \
+        --merge-profile $MERGE_PROFILE
+
+    cd $SCRIPT_DIR;
+}
+
+
 # Sets the start and end dates of the previous quarter.
 # Probably a more elegant way to do this, oh well.
 function bs_set_qtr_dates {
@@ -242,12 +284,14 @@ USAGE
 }
 
 
-while getopts "abqhd:" opt; do
+while getopts "abqhd:p:c" opt; do
     case $opt in
         d) export PGHOST=$OPTARG;;
+        p) ADMIN_PASSWORD=$OPTARG;;
         a) bs_import_monthly_auths;;
         q) bs_import_qtrly_results;;
         b) bs_export_qtrly_bibs;;
+        c) bs_import_bib_collisions;;
         h) usage;;
     esac
 done;