From: berick Date: Fri, 1 Apr 2011 21:45:12 +0000 (-0400) Subject: move to unapi.bre for bib/copy-count/slim-holdings retrieval on record results page X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=03800ae3dca7f0947d5866350138e7a745b467f9;p=evergreen%2Fequinox.git move to unapi.bre for bib/copy-count/slim-holdings retrieval on record results page --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 272a3fc06a..fe61149e06 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -139,13 +139,14 @@ sub load_rresults { return Apache2::Const::OK if @$rec_ids == 0; - my ($facets, @data) = $self->get_records_and_facets($rec_ids, $results->{facet_key}); + my ($facets, @data) = $self->get_records_and_facets( + $rec_ids, $results->{facet_key}, {flesh => '{holdings_xml}'}); # shove recs into context in search results order for my $rec_id (@$rec_ids) { push( @{$ctx->{records}}, - grep { $_->{bre}->id == $rec_id } @data + grep { $_->{id} == $rec_id } @data ); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 18fc5ce21a..361261e3e7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -145,12 +145,29 @@ sub generic_redirect { } sub get_records_and_facets { - my ($self, $rec_ids, $facet_key) = @_; - - my $cstore = OpenSRF::AppSession->create('open-ils.cstore'); - my $bre_req = $cstore->request( - 'open-ils.cstore.direct.biblio.record_entry.search', {id => $rec_ids} - ); + my ($self, $rec_ids, $facet_key, $unapi_args) = @_; + + $unapi_args ||= {}; + $unapi_args->{loc} ||= $self->ctx->{aou_tree}->()->shortname; + $unapi_args->{depth} ||= $self->ctx->{aou_tree}->()->ou_type->depth; + $unapi_args->{flesh_depth} ||= 5; + + # XXX Fire in fixed-size batches to prevent larger display limits abusing cstore + my @reqs; + for my $id (@$rec_ids) { + my $ses = OpenSRF::AppSession->create('open-ils.cstore'); + my $r = $ses->request( + 'open-ils.cstore.json_query', + {from => [ + 'unapi.bre', $id, 'marcxml','record', + $unapi_args->{flesh}, + $unapi_args->{loc}, + $unapi_args->{depth}, + $unapi_args->{flesh_depth}, + ]} + ); + push(@reqs, {req => $r, ses => $ses}); + } my $search = OpenSRF::AppSession->create('open-ils.search'); my $facet_req = $search->request( @@ -158,28 +175,17 @@ sub get_records_and_facets { ) if $facet_key; my @data; - while (my $resp = $bre_req->recv) { - my $bre = $resp->content; - - # XXX farm out to multiple cstore sessions before loop, - # then collect after - my $copy_counts = $self->editor->json_query( - {from => ['asset.record_copy_count', 1, $bre->id, 0]} - )->[0]; - - push @data, { - bre => $bre, - marc_xml => XML::LibXML->new->parse_string($bre->marc), - copy_counts => $copy_counts - }; + for my $req (@reqs) { + my $data = $req->{req}->gather(1); + $req->{ses}->kill_me; + my $xml = XML::LibXML->new->parse_string($data->{'unapi.bre'})->documentElement; + my $rec_id = $xml->find('*[@tag="901"]/*[@code="c"]')->[0]->textContent; + push(@data, {id => $rec_id, marc_xml => $xml}); } - $cstore->kill_me; - my $facets; if ($facet_key) { $facets = $facet_req->gather(1); - $facets->{$_} = { cmf => $self->ctx->{find_cmf}->($_), data => $facets->{$_} @@ -191,6 +197,7 @@ sub get_records_and_facets { return ($facets, @data); } +# TODO: blend this code w/ ^-- get_records_and_facets sub fetch_marc_xml_by_id { my ($self, $id_list) = @_; $id_list = [$id_list] unless ref($id_list); diff --git a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 index 482481d9d8..284b0a3b01 100644 --- a/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/misc_util.tt2 @@ -23,6 +23,23 @@ # clean up the ISBN args.isbn_clean = args.isbn.replace('\ .*', ''); + args.holdsing = []; + FOR holding IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); + args.holdings.push({ + # TODO + }); + END; + + # Extract the copy count summary + count_type = (ctx.is_staff) ? 'staff' : 'public'; + xpath = '//*[local-name()="counts"]/*[local-name()="count"][@type="' _ count_type _ '"]'; + FOR node IN xml.findnodes(xpath); + args.copy_counts = {}; + FOR attr IN ['count', 'available', 'unshadow', 'transcendant']; + args.copy_counts.$attr = node.getAttribute(attr); + END; + END; + # KCLS-specific stuff; needs to change args.mattype = xml.findnodes('//*[@tag="998"]/*[@code="d"]').textContent; args.kcls_cn = xml.findnodes('//*[@tag="092" or @tag="099"]/*').textContent; diff --git a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 index ddafce5d1b..a46784bc77 100644 --- a/Open-ILS/web/templates/default/opac/parts/result/table.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/result/table.tt2 @@ -76,7 +76,7 @@ [% ident = attrs.isbn_clean || attrs.upc; IF ident; %] - Image of itemImage of item
[% END %] @@ -86,7 +86,7 @@ valign="top">
[% attrs.title %]
@@ -136,7 +136,9 @@
[% l('[_1] of [quant,_2,copy,copies] available', - rec.copy_counts.available, rec.copy_counts.visible) %] + attrs.copy_counts.available, attrs.copy_counts.count) # XXX s/count/nshadow/ ? + #rec.copy_counts.available, rec.copy_counts.visible) + %]
@@ -180,16 +182,16 @@
- [% operation = ctx.mylist.grep(rec.bre.id).size ? "delete" : "add"; + [% operation = ctx.mylist.grep(rec.id).size ? "delete" : "add"; label = (operation == "add") ? "Add to" : "Remove from"; %]
- +