From: erickson Date: Thu, 20 Nov 2008 21:15:34 +0000 (+0000) Subject: optimized on-shelf holds retrieval. only grab the IDs up front and flesh transit... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=23f4c654b26a9a147f698e9a849734bff2acb73a;p=Evergreen.git optimized on-shelf holds retrieval. only grab the IDs up front and flesh transit/notices within same request git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@11290 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 6ec2104ccf..1208dafd67 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -935,11 +935,10 @@ sub flesh_hold_notices { } - - __PACKAGE__->register_method( method => 'fetch_captured_holds', api_name => 'open-ils.circ.captured_holds.on_shelf.retrieve', + stream => 1, signature => q/ Returns a list of un-fulfilled holds for a given title id @param authtoken The login session key @@ -950,6 +949,7 @@ __PACKAGE__->register_method( __PACKAGE__->register_method( method => 'fetch_captured_holds', api_name => 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', + stream => 1, signature => q/ Returns a list ids of un-fulfilled holds for a given title id @param authtoken The login session key @@ -966,36 +966,50 @@ sub fetch_captured_holds { $org ||= $e->requestor->ws_ou; - my $holds = $e->search_action_hold_request( - { - capture_time => { "!=" => undef }, - current_copy => { "!=" => undef }, - fulfillment_time => undef, - pickup_lib => $org, - cancel_time => undef, - } - ); - - my @res; - for my $h (@$holds) { - my $copy = $e->retrieve_asset_copy($h->current_copy) - or return $e->event; - push( @res, $h ) if - $copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF; - } + my $hold_ids = $e->json_query( + { + select => { ahr => ['id'] }, + from => { + ahr => { + acp => { + field => 'id', + fkey => 'current_copy' + }, + } + }, + where => { + '+acp' => { status => OILS_COPY_STATUS_ON_HOLDS_SHELF }, + '+ahr' => { + capture_time => { "!=" => undef }, + current_copy => { "!=" => undef }, + fulfillment_time => undef, + pickup_lib => $org, + cancel_time => undef, + } + } + }, + ); - if( ! $self->api_name =~ /id_list/ ) { - flesh_hold_transits(\@res); - flesh_hold_notices(\@res, $e); - } + for my $hold_id (@$hold_ids) { + if($self->api_name =~ /id_list/) { + $conn->respond($hold_id->{id}); + next; + } else { + $conn->respond( + $e->retrieve_action_hold_request([ + $hold_id->{id}, + { + flesh => 1, + flesh_fields => {ahr => ['notifications', 'transit']}, + order_by => {anh => 'notify_time desc'} + } + ]) + ); + } + } - if( $self->api_name =~ /id_list/ ) { - return [ map { $_->id } @res ]; - } else { - return \@res; - } + return undef; } - __PACKAGE__->register_method( method => "check_title_hold", api_name => "open-ils.circ.title_hold.is_possible",