From: Bill Erickson Date: Thu, 23 Jun 2016 17:39:26 +0000 (-0400) Subject: LP#? Hold targeter refactoring and optimization. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=981940fa2324dd848a5a91d172016c942f3e7b0b;p=working%2FEvergreen.git LP#? Hold targeter refactoring and optimization. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm index ae522dfd7f..9f07245ace 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm @@ -60,10 +60,9 @@ sub new { # newest_first => 1 # Target holds in reverse order of create_time. # -# retarget_nonviable => 1 -# Only retarget holds holds whose current_copy is no longer viable -# (e.g. copy was marked as non-circulate) or that have no current_copy -# set. This setting is ignored if 'hold' or 'retarget_all' are set. +# skip_viable => 1 +# Avoid retargeting holds whose current_copy is still viable and permitted. +# This setting can be used in conjunction with any other settings. # # target_all => 1 # USE WITH CAUTION. Forces (re)targeting of all active holds. This @@ -83,7 +82,7 @@ sub target { for my $hold_id ($self->find_holds_to_target) { my $single = OpenILS::Utils::HoldTargeter::Single->new( parent => $self, - retarget_nonviable => $args{retarget_nonviable} + skip_viable => $args{skip_viable} ); $single->target($hold_id); push(@responses, $single->result) unless $self->{return_count}; @@ -682,12 +681,11 @@ sub inspect_previous_target { # previous target is no longer valid. return 1 unless $prev; - if ($self->{retarget_nonviable}) { - # In retarget_nonviable mode, leave the hold as-is if + if ($self->{skip_viable}) { + # In skip_viable mode, leave the hold as-is if # the existing current_copy is still permitted. - return $self->exit_targeter( - "Skipping hold with viable target in 'retarget_nonviable' mode") + return $self->exit_targeter("Skipping with viable target = $prev_id") if $self->copy_is_permitted($prev); } @@ -992,7 +990,7 @@ sub apply_copy_target { $e->commit; $self->{success} = 1; - return $self->exit_targeter("Hold successfully targeted"); + return $self->exit_targeter("successfully targeted copy ".$copy->{id}); } # Creates a new row in action.unfulfilled_hold_list for our hold. @@ -1147,12 +1145,11 @@ sub target { return unless $self->filter_closed_date_copies; # Set aside the previously targeted copy for later use as needed. - # Code may exit here in retarget_nonviable mode if the existing + # Code may exit here in skip_viable mode if the existing # current_copy value is still viable. return unless $self->inspect_previous_target; - # Log that the hold was not captured. Logging this here is - # necessary for max-loops calculation. + # Log that the hold was not captured. return unless $self->log_unfulfilled_hold; # Confirm again we have something to work on. If we have no