From 52935eab43d98e37788b8f97f0a13a5529e184cf Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 8 Dec 2011 20:29:23 -0500 Subject: [PATCH] Use in-db unapi to display record summaries Now that we're pulling copy/location/volume/status attributes from in-db unAPI rather than mk_copy_query's massive JSON query, populate the holdings hash with the required attributes and cut over to the corresponding attributes in the record summary table. We are approaching uniform access to copy info between search results and record summaries. Signed-off-by: Dan Scott --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 15 ++------ .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm | 11 +++--- Open-ILS/src/templates/opac/parts/misc_util.tt2 | 16 ++++++-- .../src/templates/opac/parts/record/summary.tt2 | 43 ++++++++++------------ 4 files changed, 42 insertions(+), 43 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 0f714c9a1d..00287f0bed 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -15,6 +15,7 @@ sub load_record { $ctx->{page} = 'record'; my $org = $self->cgi->param('loc') || $ctx->{aou_tree}->()->id; + my $site = $ctx->{get_aou}->($org)->shortname; my $depth = $self->cgi->param('depth') || 0; my $copy_limit = int($self->cgi->param('copy_limit') || 10); my $copy_offset = int($self->cgi->param('copy_offset') || 0); @@ -29,19 +30,13 @@ sub load_record { $self->fetch_related_search_info($rec_id); - # run copy retrieval in parallel to bib retrieval - # XXX unapi - my $cstore = OpenSRF::AppSession->create('open-ils.cstore'); - my $copy_rec = $cstore->request( - 'open-ils.cstore.json_query.atomic', - $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset) + my (undef, @rec_data) = $self->get_records_and_facets( + [$rec_id], undef, {flesh => '{holdings_xml,mra,acp,acnp,acns,circ}'}, + $site, $depth, $copy_limit, $copy_offset ); - - my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra,acp}'}); $ctx->{bre_id} = $rec_data[0]->{id}; $ctx->{marc_xml} = $rec_data[0]->{marc_xml}; - $ctx->{copies} = $copy_rec->gather(1); $ctx->{copy_limit} = $copy_limit; $ctx->{copy_offset} = $copy_offset; @@ -49,8 +44,6 @@ sub load_record { $ctx->{have_mfhd_to_show} = 0; $self->get_hold_copy_summary($rec_id, $org); - $cstore->kill_me; - if ( $ctx->{get_org_setting}-> ($org, "opac.fully_compressed_serial_holdings") 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 1199d9ae38..f1607c5d13 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -165,12 +165,13 @@ sub generic_redirect { } sub get_records_and_facets { - my ($self, $rec_ids, $facet_key, $unapi_args) = @_; + my ($self, $rec_ids, $facet_key, $unapi_args, $org, $depth, $copy_limit, $copy_offset) = @_; $unapi_args ||= {}; - $unapi_args->{site} ||= $self->ctx->{aou_tree}->()->shortname; - $unapi_args->{depth} ||= $self->ctx->{aou_tree}->()->ou_type->depth; - $unapi_args->{flesh_depth} ||= 5; + $unapi_args->{site} = $org || $self->ctx->{aou_tree}->()->shortname; + $unapi_args->{depth} = $depth || $self->ctx->{aou_tree}->()->ou_type->depth; + $copy_limit ||= 5; + $copy_offset ||= 0; my @data; my $ses = OpenSRF::MultiSession->new( @@ -200,7 +201,7 @@ sub get_records_and_facets { $unapi_args->{flesh}, $unapi_args->{site}, $unapi_args->{depth}, - $unapi_args->{flesh_depth}, + $copy_limit, $copy_offset ]} ) for @$rec_ids; diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index db30d6b3d7..e4677f3a20 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -131,13 +131,23 @@ loc = copy.findnodes('./*[local-name()="location"]'); circlib = copy.findnodes('./*[local-name()="circlib"]'); status = copy.findnodes('./*[local-name()="status"]'); + circ = copy.findnodes('./*[local-name()="circ"]'); holding = { + age_protect => copy.getAttribute('age_protect'), + barcode => copy.getAttribute('barcode'), + copy_id => copy.getAttribute('copy_id'), + create_date => copy.getAttribute('create_date'), + due_date = circ.getAttribute('due_date') + holdable => copy.getAttribute('holdable'), + id => copy.getAttribute('id'), label => vol.label, - location => loc.textContent, library => circlib.textContent, - status => status.textContent - barcode => copy.getAttribute('barcode') + location => loc.textContent, + loc_holdable => loc.getAttribute('holdable'), + status_holdable => status.getAttribute('holdable'), + status => status.textContent, + vol_id => vol.getAttribute('vol_id') }; args.holdings.push(holding); END; diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index 540c30d8cf..c6a7164d00 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -117,51 +117,46 @@ IF num_uris > 0; [%- last_cn = 0; - FOR copy_info IN ctx.copies; - NEXT IF copy_info.call_number_label == '##URI##' %] + FOR copy IN args.holdings; + NEXT IF copy.label == '##URI##' %] - - [%- - org_name = ctx.get_aou(copy_info.circ_lib).name; - org_name | html - -%] - - [% copy_info.call_number_label | html %] - [% copy_info.barcode | html %] - [% copy_info.copy_location | html %] + [% copy.library | html -%] + [% copy.label | html %] + [% copy.barcode | html %] + [% copy.location | html %] [%- IF ctx.is_staff %] - [% copy_info.age_protect ? - ctx.get_crahp(copy_info.age_protect).name : l('None') | html %] + [% copy.age_protect ? + ctx.get_crahp(copy.age_protect).name : l('None') | html %] [% date.format( - ctx.parse_datetime(copy_info.create_date), + ctx.parse_datetime(copy.create_date), DATE_FORMAT ) %] [% # Show copy/volume hold links to staff (without # checking whether they have permissions to do those). - overall_holdable = (copy_info.holdable == 't' AND - copy_info.location_holdable == 't' AND - copy_info.status_holdable == 't'); + overall_holdable = (copy.holdable == 't' AND + copy.loc_holdable == 't' AND + copy.status_holdable == 't'); IF overall_holdable; l("Place on"); %] [% l("copy") %] - [%- IF copy_info.call_number != last_cn; - last_cn = copy_info.call_number; + {hold_target => copy.copy_id, hold_type => 'C', hold_source_page => mkurl()}) %]">[% l("copy") %] + [%- IF copy.vol_id != last_cn; + last_cn = copy.vol_id; l(" / "); %] [% l("volume") %] + {hold_target => copy.vol_id, hold_type => 'V', hold_source_page => mkurl()}) %]">[% l("volume") %] [%- END; ELSE; l("No"); END %] [%- END %] - [% copy_info.copy_status | html %] + [% copy.status | html %] [% - IF copy_info.due_date; + IF copy.due_date; date.format( - ctx.parse_datetime(copy_info.due_date), + ctx.parse_datetime(copy.due_date), DATE_FORMAT ); ELSE; -- 2.11.0