From 414876e9f129b1b03f35e18eddafd24c53d58300 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 6 Jul 2010 18:58:54 +0000 Subject: [PATCH] add metarecord support to "already circulated" tagging git-svn-id: svn://svn.open-ils.org/ILS/trunk@16856 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Search/Biblio.pm | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 8f45cd8a5..d93d7a798 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -1084,7 +1084,9 @@ __PACKAGE__->register_method( sub staged_search { my($self, $conn, $search_hash, $docache) = @_; - my $method = ($self->api_name =~ /metabib/) ? + my $IAmMetabib = ($self->api_name =~ /metabib/) ? 1 : 0; + + my $method = $IAmMetabib? 'open-ils.storage.metabib.multiclass.staged.search_fts': 'open-ils.storage.biblio.multiclass.staged.search_fts'; @@ -1173,16 +1175,15 @@ sub staged_search { } # Create backwards-compatible result structures - if($self->api_name =~ /biblio/) { - $results = [map {[$_->{id}]} @$results]; - - tag_circulated_records($search_hash->{authtoken}, $results) - if $search_hash->{tag_circulated_records} and $search_hash->{authtoken}; - - } else { + if($IAmMetabib) { $results = [map {[$_->{id}, $_->{rel}, $_->{record}]} @$results]; + } else { + $results = [map {[$_->{id}]} @$results]; } + tag_circulated_records($search_hash->{authtoken}, $results, $IAmMetabib) + if $search_hash->{tag_circulated_records} and $search_hash->{authtoken}; + push @$new_ids, grep {defined($_)} map {$_->[0]} @$results; $results = [grep {defined $_->[0]} @$results]; cache_staged_search_page($key, $page, $summary, $results) if $docache; @@ -1254,34 +1255,39 @@ sub staged_search { } ); - cache_facets($facet_key, $new_ids, ($self->api_name =~ /metabib/) ? 1 : 0) if $docache; + cache_facets($facet_key, $new_ids, $IAmMetabib) if $docache; return undef; } sub tag_circulated_records { - my ($auth, $results) = @_; + my ($auth, $results, $metabib) = @_; my $e = new_editor(authtoken => $auth); return $results unless $e->checkauth; + my $query = { + select => { acn => [{ column => 'record', alias => 'tagme' }] }, + from => { acp => 'acn' }, + where => { id => { in => { from => ['action.usr_visible_circ_copies', $e->requestor->id] } } }, + distinct => 1 + }; + + if ($metabib) { + $query = { + select => { mmsm => [{ column => 'metarecord', alias => 'tagme' }] }, + from => 'mmsm', + where => { source => { in => $query } }, + distinct => 1 + }; + } + # Give me the distinct set of bib records that exist in the user's visible circulation history - my $circ_recs = $e->json_query({ - select => {acn => [{column => 'record', transform => 'distinct'}]}, - from => {acp => 'acn'}, - where => { - '+acp' => { - id => { - in => { - from => ['action.usr_visible_circ_copies', $e->requestor->id]} - } - } - } - }); + my $circ_recs = $e->json_query( $query ); # if the record appears in the circ history, push a 1 onto # the rec array structure to indicate truthiness for my $rec (@$results) { - push(@$rec, 1) if grep { $_->{record} eq $$rec[0] } @$circ_recs; + push(@$rec, 1) if grep { $_->{tagme} eq $$rec[0] } @$circ_recs; } $results -- 2.11.0