TPac; display hold count in results page
authorBill Erickson <berick@esilibrary.com>
Wed, 9 Nov 2011 21:44:10 +0000 (16:44 -0500)
committerBill Erickson <berick@esilibrary.com>
Tue, 5 Jun 2012 14:09:42 +0000 (10:09 -0400)
Using same wording and layout as kcls jspac skin.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm

index 1bf8b61..0b991dc 100644 (file)
@@ -429,7 +429,8 @@ sub load_rresults {
             site => $site,
             depth => $depth,
             pref_lib => $ctx->{pref_ou},
-        }
+        },
+        1
     );
     $self->timelog("Returned from get_records_and_facets()");
 
index 498a04f..39ebb2d 100644 (file)
@@ -215,7 +215,7 @@ sub generic_redirect {
 }
 
 sub get_records_and_facets {
-    my ($self, $rec_ids, $facet_key, $unapi_args) = @_;
+    my ($self, $rec_ids, $facet_key, $unapi_args, $get_hold_stats) = @_;
 
     $unapi_args ||= {};
     $unapi_args->{site} ||= $self->ctx->{aou_tree}->()->shortname;
@@ -275,10 +275,27 @@ sub get_records_and_facets {
         'open-ils.search.facet_cache.retrieve', $facet_key, 10
     ) if $facet_key;
 
+
     # gather up the unapi recs
     $ses->session_wait(1);
     $self->timelog("get_records_and_facets():past session wait");
 
+    if ($get_hold_stats) {
+        # note: this happens after the batch unapi call to ensure 
+        # that @data has the record blobs we're expecting.
+        my $hses = OpenSRF::MultiSession->new(
+            app => 'open-ils.circ',
+            cap => 10, # XXX config
+            success_handler => sub {
+                my($self, $req) = @_;
+                my ($blob) = grep {$_->{id} eq $req->{params}->[0]} @data;
+                $blob->{hold_count} = $req->{response}->[0]->content;
+            }
+        );
+        $hses->request('open-ils.circ.bre.holds.count', $_) for @$rec_ids;
+        $hses->session_wait(1);
+    }
+
     my $facets = {};
     if ($facet_key) {
         my $tmp_facets = $facet_req->gather(1);