From 68db49b19849963e95e7f94c69523cc290fd9fda Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 21 Aug 2012 17:19:54 -0400 Subject: [PATCH] Clear-shelf includes pickup-lib changes : Perl Signed-off-by: Bill Erickson --- .../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index b72db96635..3d689ce247 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -3449,10 +3449,19 @@ sub clear_shelf_process { if ($e->commit) { + + my %cache_data = ( hold => [], transit => [], - shelf => [] + shelf => [], + + # if requested, find any holds on our shelf whose pickup lib + # has been changed to some other branch and include those in + # the clear-shelf cache. But, only add them to the pl_changed + # list if they are not otherwise getting canceled by this process. + pl_changed => 1 ? # TODO ORG SETTING + pickup_lib_changed_on_shelf_holds($e, $org_id, @hold_ids) : [] ); for my $hold (@holds) { @@ -3501,6 +3510,40 @@ sub clear_shelf_process { } } +# returns IDs for holds that are on the holds shelf but +# have had their pickup_libs change while on the shelf. +sub pickup_lib_changed_on_shelf_holds { + my $e = shift; + my $org_id = shift; + my $ignore_holds = shift; + + my $query = { + select => { alhr => ['id'] }, + from => { + alhr => { + acp => { + field => 'id', + fkey => 'current_copy' + }, + } + }, + where => { + '+acp' => { status => OILS_COPY_STATUS_ON_HOLDS_SHELF }, + '+alhr' => { + capture_time => { "!=" => undef }, + fulfillment_time => undef, + current_shelf_lib => $org_id, + pickup_lib => {'!=' => {'+alhr' => 'current_shelf_lib'}} + } + } + }; + + $query->{where}->{'+alhr'}->{id} = {'!=' => $ignore_holds} if $ignore_holds; + + my $hold_ids = $e->json_query($query); + return map { $_->{id} } @$hold_ids; +} + __PACKAGE__->register_method( method => 'usr_hold_summary', api_name => 'open-ils.circ.holds.user_summary', -- 2.11.0