1 package OpenILS::Application::HoldTargeter;
4 use OpenILS::Application;
5 use base qw/OpenILS::Application/;
6 use OpenILS::Utils::HoldTargeter;
8 __PACKAGE__->register_method(
9 method => 'hold_targeter',
10 api_name => 'open-ils.hold-targeter.target',
14 # Caller is given control over how often to receive responses.
17 desc => q/Batch or single hold targeter./,
20 desc => 'Hash of targeter options',
34 # return_count - Return number of holds processed so far instead
35 # of hold targeter result summary objects.
37 # return_throttle - Only reply each time this many holds have been
38 # targeted. This prevents dumping a fast stream of responses
39 # at the client if the client doesn't need them.
41 # See OpenILS::Utils::HoldTargeter::target() docs.
44 my ($self, $client, $args) = @_;
46 my $targeter = OpenILS::Utils::HoldTargeter->new(%$args);
50 my $throttle = $args->{return_throttle} || 1;
53 for my $hold_id ($targeter->find_holds_to_target) {
56 my $single = OpenILS::Utils::HoldTargeter::Single->new(
58 skip_viable => $args->{skip_viable}
61 $single->target($hold_id);
63 if (($count % $throttle) == 0) {
64 # Time to reply to the caller. Return either the number
65 # processed thus far or the most recent summary object.
67 my $res = $args->{return_count} ? $count : $single->result;
68 $client->respond($res);