From: Bill Erickson Date: Wed, 15 Jun 2016 17:55:40 +0000 (-0400) Subject: hold targeter reify experiment X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=077781b3fbab465a3e16b7a98d6a217e32252cec;p=working%2FEvergreen.git hold targeter reify experiment 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 6cd8be5c03..4a29a077eb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm @@ -654,20 +654,23 @@ sub inspect_previous_target { return 1; } -# Returns true if we have at least one potential copy, thus targeting -# should continue. Otherwise, the hold is updated to reflect that -# there is no target and returns false, to stop targeting. +# Returns true if we have at least one potential copy remaining, thus +# targeting should continue. Otherwise, the hold is updated to reflect +# that there is no target and returns false to stop targeting. sub handle_no_copies { my ($self, %args) = @_; if (!$args{force}) { - # Force just says don't bother checking the copies, - # because other code already has. + # If 'force' is set, the caller is saying that all copies have + # failed. Otherwise, see if we have any copies left to inspect. return 1 if @{$self->copies} || $self->{valid_previous_copy}; } + # At this point, all copies have been inspected and none + # have yielded a targetable item. + if ($args{process_recalls}) { - # See if we have any copies to recall. + # See if we have any copies/circs to recall. return unless $self->process_recalls; } @@ -874,6 +877,9 @@ sub find_nearest_copy { return undef; } +# Returns true if the provided copy passes the hold permit test for our +# hold and can be used for targeting. +# When a copy fails the test, it is removed from $self->copies. sub copy_is_permitted { my ($self, $copy) = @_; return 0 unless $copy; @@ -900,6 +906,7 @@ sub copy_is_permitted { return 0; } +# Sets hold.current_copy to the provided copy. sub apply_copy_target { my ($self, $copy) = @_; my $e = $self->editor; @@ -916,6 +923,7 @@ sub apply_copy_target { return $self->exit_targeter("Hold successfully targeted"); } +# Creates a new row in action.unfulfilled_hold_list for our hold. # Returns 1 if all is OK, false on error. sub log_unfulfilled_hold { my $self = shift; @@ -1089,9 +1097,7 @@ sub target { return $self->apply_copy_target($copy) if $copy; - # No targetable copy was found. Fire the no-copy - # handler to update the hold accordingly. - + # No targetable copy was found. Fire the no-copy handler. $self->handle_no_copies(force => 1, process_recalls => 1); }