From 7a5180f0d0d6c197ac5a22cc59b1cd042a9e0e4a Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 29 Oct 2009 13:30:46 +0000 Subject: [PATCH] added API call for just grabbing canceled holds git-svn-id: svn://svn.open-ils.org/ILS/trunk@14672 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/Holds.pm | 105 +++++++++++------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index b43b9bef2e..0e018d10de 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -317,6 +317,20 @@ user id. The login session is the requestor and if the requestor is different from the user, then the requestor must have VIEW_HOLD permissions. NOTE + +__PACKAGE__->register_method( + method => "retrieve_holds", + authoritative => 1, + api_name => "open-ils.circ.holds.canceled.retrieve", +); + +__PACKAGE__->register_method( + method => "retrieve_holds", + authoritative => 1, + api_name => "open-ils.circ.holds.canceled.id_list.retrieve", +); + + sub retrieve_holds { my($self, $client, $auth, $user_id, $options) = @_; @@ -334,50 +348,59 @@ sub retrieve_holds { } } - my $holds = $e->search_action_hold_request([ - { usr => $user_id , - fulfillment_time => undef, - cancel_time => undef, - }, - {order_by => {ahr => "request_time"}} - ]); + my $holds; - my $cancel_age; - my $cancel_count = - $U->ou_ancestor_setting_value( - $e->requestor->ws_ou, 'circ.holds.canceled.display_count', $e); + if($self->api_name !~ /canceled/) { - unless($cancel_count) { - $cancel_age = $U->ou_ancestor_setting_value( - $e->requestor->ws_ou, 'circ.holds.canceled.display_age', $e); - } + # Fetch the active holds + + $holds = $e->search_action_hold_request([ + { usr => $user_id , + fulfillment_time => undef, + cancel_time => undef, + }, + {order_by => {ahr => "request_time"}} + ]); + + } else { + + # Fetch the canceled holds + + my $cancel_age; + my $cancel_count = + $U->ou_ancestor_setting_value( + $e->requestor->ws_ou, 'circ.holds.canceled.display_count', $e); - if($cancel_count) { - - # find at most cancel_count canceled holds - my $canceled = $e->search_action_hold_request([ - { usr => $user_id , - fulfillment_time => undef, - cancel_time => {'!=' => undef}, - }, - {order_by => {ahr => "cancel_time desc"}, limit => $cancel_count} - ]); - push(@$holds, @$canceled); - - } elsif($cancel_age) { - - # find all of the canceled holds that were canceled within the configured time frame - my $date = DateTime->now->subtract(seconds => OpenSRF::Utils::interval_to_seconds($cancel_age)); - $date = $U->epoch2ISO8601($date->epoch); - - my $canceled = $e->search_action_hold_request([ - { usr => $user_id , - fulfillment_time => undef, - cancel_time => {'>=' => $date}, - }, - {order_by => {ahr => "cancel_time desc"}} - ]); - push(@$holds, @$canceled); + unless($cancel_count) { + $cancel_age = $U->ou_ancestor_setting_value( + $e->requestor->ws_ou, 'circ.holds.canceled.display_age', $e); + } + + if($cancel_count) { # limit by count + + # find at most cancel_count canceled holds + $holds = $e->search_action_hold_request([ + { usr => $user_id , + fulfillment_time => undef, + cancel_time => {'!=' => undef}, + }, + {order_by => {ahr => "cancel_time desc"}, limit => $cancel_count} + ]); + + } elsif($cancel_age) { # limit by age + + # find all of the canceled holds that were canceled within the configured time frame + my $date = DateTime->now->subtract(seconds => OpenSRF::Utils::interval_to_seconds($cancel_age)); + $date = $U->epoch2ISO8601($date->epoch); + + $holds = $e->search_action_hold_request([ + { usr => $user_id , + fulfillment_time => undef, + cancel_time => {'>=' => $date}, + }, + {order_by => {ahr => "cancel_time desc"}} + ]); + } } if( ! $self->api_name =~ /id_list/ ) { -- 2.43.2