From: Bill Erickson Date: Mon, 27 Jun 2016 14:18:16 +0000 (-0400) Subject: LP#? Hold targeter refactoring and optimization. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=eabfb98d08ad2d03c5c16bf0d34e4f814dc294cc;p=working%2FEvergreen.git LP#? Hold targeter refactoring and optimization. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/support-scripts/hold_targeter.pl b/Open-ILS/src/support-scripts/hold_targeter.pl index a046238276..d6549ea553 100755 --- a/Open-ILS/src/support-scripts/hold_targeter.pl +++ b/Open-ILS/src/support-scripts/hold_targeter.pl @@ -1,13 +1,12 @@ #!/usr/bin/perl -#---------------------------------------------------------------- -# Batch hold targeter -#---------------------------------------------------------------- use strict; use warnings; use OpenSRF::System; use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::HoldTargeter; #---------------------------------------------------------------- +# Batch hold (re)targeter +# # Usage: # ./hold_targeter.pl /openils/conf/opensrf_core.xml #---------------------------------------------------------------- @@ -15,13 +14,12 @@ use OpenILS::Utils::HoldTargeter; my $osrf_config = shift || '/openils/conf/opensrf_core.xml'; my $lockfile = shift || "/tmp/hold_targeter-LOCK"; -if (-e $lockfile) { - die "I seem to be running already. If not remove $lockfile, try again\n"; -} +die "I seem to be running already. If not remove $lockfile, try again\n" + if -e $lockfile; -open(F, ">$lockfile") or die "Cannot open lock file: $lockfile : $@\n"; -print F $$ or die "Cannot write to lock file: $lockfile : $@\n"; -close F; +open(LOCK, ">$lockfile") or die "Cannot open lock file: $lockfile : $@\n"; +print LOCK $$ or die "Cannot write to lock file: $lockfile : $@\n"; +close LOCK; eval { # Make sure we can delete the lock file. @@ -34,12 +32,11 @@ eval { # Make sure we can delete the lock file. my $start = time; my $count = $targeter->target( - # Return only the number processed, - # instead of a result blob for each hold. - return_count => 1 + #skip_viable => 1, # Testing: only re-target non-viable holds. + return_count => 1 # Return count, not per-hold results. ); - my $minutes = sprintf('%0.2f', (time - $start) / 60); + my $minutes = sprintf('%0.2f', (time - $start) / 60.0); print "Processed $count holds in $minutes minutes.\n"; };