From f7fc7fa2a1bac404317a7ba549beaf73d56c0ac5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 4 Aug 2014 13:10:49 -0400 Subject: [PATCH] LP#1350042 streaming patron search API Adds an API name-based option to the standard patron search API to respond with a stream of fleshed users, so the caller is not forced to make additional fetch-by-ID calls to collect the user data. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- .../perlmods/lib/OpenILS/Application/Actor.pm | 37 +++++++++++++++++-- .../Application/Storage/Publisher/actor.pm | 2 + 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 4dd3c013ef..be97787a27 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1317,9 +1317,30 @@ __PACKAGE__->register_method( method => "patron_adv_search", api_name => "open-ils.actor.patron.search.advanced" ); + +__PACKAGE__->register_method( + method => "patron_adv_search", + api_name => "open-ils.actor.patron.search.advanced.fleshed", + stream => 1, + # TODO: change when opensrf 'bundling' is merged. + # set a relatively small bundle size so the caller can start + # seeing results fairly quickly + max_chunk_size => 4096, # bundling + + # api_level => 2, + # pending opensrf work -- also, not sure if needed since we're not + # actaully creating an alternate vesrion, only offering to return a + # different format. + # + signature => { + desc => q/Returns a stream of fleshed user objects instead of + a pile of identifiers/ + } +); + sub patron_adv_search { - my( $self, $client, $auth, $search_hash, - $search_limit, $search_sort, $include_inactive, $search_ou ) = @_; + my( $self, $client, $auth, $search_hash, $search_limit, + $search_sort, $include_inactive, $search_ou, $flesh_fields, $offset) = @_; my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; @@ -1341,9 +1362,17 @@ sub patron_adv_search { ); } } - return $U->storagereq( + + my $ids = $U->storagereq( "open-ils.storage.actor.user.crazy_search", $search_hash, - $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_ou, $opt_boundary); + $search_limit, $search_sort, $include_inactive, + $e->requestor->ws_ou, $search_ou, $opt_boundary, $offset); + + return $ids unless $self->api_name =~ /fleshed/; + + $client->respond(new_flesh_user($_, $flesh_fields, $e)) for @$ids; + + return; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm index 06117ff682..f55da8c998 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm @@ -642,6 +642,7 @@ sub patron_search { my $ws_ou = shift; my $search_org = shift || $ws_ou; my $opt_boundary = shift || 0; + my $offset = shift || 0; my $penalty_sort = 0; @@ -796,6 +797,7 @@ sub patron_search { GROUP BY $group_list ORDER BY $order_by LIMIT $limit + OFFSET $offset SQL return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv,@phonev,@identv,@namev,@addrv)); -- 2.43.2