From c16cfd0f680c7d28b8d201ec79618e2aeac6ff72 Mon Sep 17 00:00:00 2001 From: Bill Ott Date: Thu, 8 Jun 2017 14:30:39 -0400 Subject: [PATCH] Consider aous hold_shelf delay when displaying available hold count. Signed-off-by: Bill Ott --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 6cc2e8b558..7de106075e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -2024,7 +2024,7 @@ sub hold_request_count { } my $holds = $e->json_query({ - select => {ahr => ['pickup_lib', 'current_shelf_lib', 'behind_desk']}, + select => {ahr => ['pickup_lib', 'current_shelf_lib', 'shelf_time', 'behind_desk']}, from => 'ahr', where => { usr => $user_id, @@ -2033,9 +2033,33 @@ sub hold_request_count { } }); + my $now = DateTime->now(time_zone => 'local'); + foreach (@$holds){ + if($_->{current_shelf_lib}) { + my $delay = $e->json_query({ + select => {aous => ['value']}, + from => 'aous', + where => { + name => {"=" => 'circ.hold_shelf_status_delay'}, + org_unit => {"=" => $_->{current_shelf_lib}} + } + })->[0]; + + my $dtime = DateTime::Format::ISO8601->parse_datetime(clense_ISO8601($_->{shelf_time})); + if ($delay->{value}){ + $dtime->add( seconds => OpenSRF::Utils::interval_to_seconds($delay->{value}) ); + $_->{delay} = $dtime; + }else{ + $_->{delay} = $now; + } + $logger->info("now / delay / dleay_date ".$now." / ". $delay->{value}." / ".$dtime); + } + } + my @ready = grep { $_->{current_shelf_lib} and # avoid undef warnings $_->{pickup_lib} eq $_->{current_shelf_lib} + and $now ge $_->{delay} } @$holds; my $resp = { -- 2.11.0