From d1c2d9c45d15d882d42bb48a7411717a8b7b347e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 31 Mar 2017 10:21:25 -0400 Subject: [PATCH] LP#1677661 Targeter V2 remove unused batch API Remove the unusued batch target() function from Utils::HoldTargeter to avoid code duplication. The same (but more resilient) batch targeting construct exists in the open-ils.hold-targeter API. Move API docs from Utils::HoldTargeter to the open-ils.hold-targeter API docs for added visbility / findability. Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- .../lib/OpenILS/Application/HoldTargeter.pm | 61 ++++++++++++----- .../lib/OpenILS/Utils/HoldTargeter.pm | 68 +------------------ 2 files changed, 45 insertions(+), 84 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/HoldTargeter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/HoldTargeter.pm index 22fd3e9e51..afca2fcc9e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/HoldTargeter.pm @@ -18,29 +18,54 @@ __PACKAGE__->register_method( desc => q/Batch or single hold targeter./, params => [ { name => 'args', - desc => 'Hash of targeter options', - type => 'hash' + type => 'hash', + desc => q/ +API Options: + +return_count - Return number of holds processed so far instead + of hold targeter result summary objects. + +return_throttle - Only reply each time this many holds have been + targeted. This prevents dumping a fast stream of responses + at the client if the client doesn't need them. + +Targeter Options: + +hold => OR [, , ...] + (Re)target one or more specific holds. Specified as a single hold ID + or an array ref of hold IDs. + +retarget_interval => + Override the 'circ.holds.retarget_interval' global_flag value. + +soft_retarget_interval => + Apply soft retarget logic to holds whose prev_check_time sits + between the retarget_interval and the soft_retarget_interval. + +next_check_interval => + Use this interval to determine when the targeter will run next + instead of relying on the retarget_interval. This value is used + to determine if an org unit will be closed during the next iteration + of the targeter. Applying a specific interval is useful when + the retarget_interval is shorter than the time between targeter runs. + +newest_first => 1 + Target holds in reverse order of create_time. + +parallel_count => n + Number of parallel targeters running. This acts as the indication + that other targeter instances are running. + +parallel_slot => n [starts at 1] + Sets the parallel targeter instance slot. Used to determine + which holds to process to avoid conflicts with other running instances. +/ } ], - return => { - desc => q/ - TODO - / - } + return => {desc => 'See API Options for return types'} } ); -# args: -# -# return_count - Return number of holds processed so far instead -# of hold targeter result summary objects. -# -# return_throttle - Only reply each time this many holds have been -# targeted. This prevents dumping a fast stream of responses -# at the client if the client doesn't need them. -# -# See OpenILS::Utils::HoldTargeter::target() docs. - sub hold_targeter { my ($self, $client, $args) = @_; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm index b8553d3bec..9aab446002 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/HoldTargeter.pm @@ -26,7 +26,7 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/; our $U = "OpenILS::Application::AppUtils"; our $dt_parser = DateTime::Format::ISO8601->new; -# See target() for runtime arguments. +# See open-ils.hold-targeter API docs for runtime arguments. sub new { my ($class, %args) = @_; my $self = { @@ -37,71 +37,7 @@ sub new { return bless($self, $class); } -# Target and retarget holds. -# By default, targets all holds that need targeting, meaning those that -# have either never been targeted or those whose prev_check_time exceeds -# the retarget interval. -# -# Returns an array of targeter response objects, one entry per hold -# targeted. See also return_count. -# -# Optional parameters: -# -# hold => / [, , ...] -# (Re)target one or more specific holds. Specified as a single hold ID -# or an array ref of hold IDs. -# -# return_count => 1 -# Return the total number of holds processed instead of a result -# object for every targeted hold. Ideal for large batch targeting. -# -# retarget_interval => -# Override the 'circ.holds.retarget_interval' global_flag value. -# -# soft_retarget_interval => -# Apply soft retarget logic to holds whose prev_check_time sits -# between the retarget_interval and the soft_retarget_interval. -# -# next_check_interval => -# Use this interval to determine when the targeter will run next -# instead of relying on the retarget_interval. This value is used -# to determine if an org unit will be closed during the next iteration -# of the targeter. Applying a specific interval is useful when -# the retarget_interval is shorter than the time between targeter runs. -# -# newest_first => 1 -# Target holds in reverse order of create_time. -# -# parallel_count => n -# Number of parallel targeters running. This acts as the indication -# that other targeter instances are running. -# -# parallel_slot => n [starts at 1] -# Sets the parallel targeter instance position/slot. Used to determine -# which holds to process to avoid conflicts with other running instances. -# -sub target { - my ($self, %args) = @_; - - $self->{$_} = $args{$_} for keys %args; - - $self->init; - - my $count = 0; - my @responses; - - for my $hold_id ($self->find_holds_to_target) { - my $single = - OpenILS::Utils::HoldTargeter::Single->new(parent => $self); - - $single->target($hold_id); - push(@responses, $single->result) unless $self->{return_count}; - $count++; - } - - return $self->{return_count} ? $count : \@responses; -} - +# Returns a list of hold ID's sub find_holds_to_target { my $self = shift; -- 2.43.2