From 097d661976213564d516cebba31b2b132ae8ab13 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 3 Mar 2014 11:52:57 -0500 Subject: [PATCH] LP#1284864 MR opac-visible constituent records The number of constituent records for a metarecord during searching is now consitently based on the presence of an opac visible copy and not a holdable copy. This affects the constituent record counts in MR results lists and the records displayed in the constituent records list. (Icons were already checking visibility instead of holdability). Holdable formats are still derived from records with holdable copies. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../src/perlmods/lib/OpenILS/Application/Circ/Holds.pm | 6 +++++- .../OpenILS/Application/Storage/Publisher/action.pm | 18 ++++++++++++++++-- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index ac3ade207f..3bf21573e6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -2498,9 +2498,13 @@ sub MR_filter_records { my $f = shift; my $o = shift; my $d = shift; + my $opac_visible = shift; my $org_at_depth = defined($d) ? $U->org_unit_ancestor_at_depth($o, $d) : $o; - return $U->storagereq('open-ils.storage.metarecord.filtered_records.atomic', $m, $f, $org_at_depth); + return $U->storagereq( + 'open-ils.storage.metarecord.filtered_records.atomic', + $m, $f, $org_at_depth, $opac_visible + ); } __PACKAGE__->register_method( method => 'MR_filter_records', diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 713c10782f..7cc2086efb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -1290,6 +1290,8 @@ sub MR_records_matching_format { my $MR = shift; my $filter = shift; my $org = shift; + # include all visible copies, regardless of holdability + my $opac_visible = shift; # find filters for MR holds my $mr_filter; @@ -1303,10 +1305,22 @@ sub MR_records_matching_format { my $records = [metabib::metarecord->retrieve($MR)->source_records]; - my $q = 'SELECT source FROM metabib.record_attr_vector_list WHERE source = ? AND vlist @@ ? AND asset.record_has_holdable_copy(?,?)'; + my $vis_q = 'asset.record_has_holdable_copy(?,?)'; + if ($opac_visible) { + $vis_q = <<' SQL'; + EXISTS( + SELECT 1 FROM asset.opac_visible_copies + WHERE record = ? AND circ_lib IN ( + SELECT id FROM actor.org_unit_descendants(?) + ) + ) + SQL + } + + my $q = "SELECT source FROM metabib.record_attr_vector_list WHERE source = ? AND vlist @@ ? AND $vis_q"; my @args = ( $mr_filter, $org ); if (!$mr_filter) { - $q = 'SELECT true WHERE asset.record_has_holdable_copy(?,?)'; + $q = "SELECT true WHERE $vis_q"; @args = ( $org ); } 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 955fce3ce1..21d96e23ba 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -301,10 +301,12 @@ sub recs_from_metarecord { my ($self, $mr_id, $org, $depth, $filter) = @_; $self->timelog("Getting metarecords to records"); + # in the context of searching, we include all records which + # have an opac-visible copy. my $bre_ids = $U->simplereq( 'open-ils.circ', 'open-ils.circ.holds.metarecord.filtered_records', - $mr_id, $filter, $org, $depth); + $mr_id, $filter, $org, $depth, 1); $self->timelog("Got metarecords to records"); return $bre_ids; -- 2.11.0