From 94f32e2873d0c6236a983a86baf188957978864e Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 11 Feb 2008 16:21:49 -0600 Subject: [PATCH] FRBR: fixed paging through grouped results Signed-off-by: Joshua Ferraro --- C4/Search.pm | 16 ++++++++++------ opac/opac-search.pl | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index a7d8ecf3d8..2235d62290 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -21,6 +21,8 @@ use C4::Context; use C4::Biblio; # GetMarcFromKohaField use C4::Koha; # getFacets use Lingua::Stem; +use C4::Search::PazPar2; +use XML::Simple; use C4::Dates qw(format_date); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); @@ -611,9 +613,6 @@ sub getRecords { return ( undef, $results_hashref, \@facets_loop ); } -use C4::Search::PazPar2; -use XML::Simple; -use Data::Dumper; sub pazGetRecords { my ( $koha_query, $simple_query, $sort_by_ref, $servers_ref, @@ -629,9 +628,14 @@ sub pazGetRecords { # do results my $results_hashref = {}; my $stats = XMLin($paz->stat); - $results_hashref->{'biblioserver'}->{'hits'} = $stats->{'hits'}; my $results = XMLin($paz->show($offset, $results_per_page, 'work-title:1'), forcearray => 1); - + + # for a grouped search result, the number of hits + # is the number of groups returned; 'bib_hits' will have + # the total number of bibs. + $results_hashref->{'biblioserver'}->{'hits'} = $results->{'merged'}->[0]; + $results_hashref->{'biblioserver'}->{'bib_hits'} = $stats->{'hits'}; + HIT: foreach my $hit (@{ $results->{'hit'} }) { my $recid = $hit->{recid}->[0]; @@ -655,7 +659,7 @@ sub pazGetRecords { for (my $i = 0; $i < $count; $i++) { # FIXME -- may need to worry about diacritics here my $rec = $paz->record($recid, $i); - push @{ $result_group->{'RECORDS'} }, $paz->record($recid, $i); + push @{ $result_group->{'RECORDS'} }, $rec; } push @{ $results_hashref->{'biblioserver'}->{'GROUPS'} }, $result_group; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index a3d326f70d..f35a113c00 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -335,7 +335,10 @@ for (my $i=0;$i<=@servers;$i++) { my @newresults; if ($build_grouped_results) { foreach my $group (@{ $results_hashref->{$server}->{"GROUPS"} }) { - my @group_results = searchResults( $query_desc, $group->{'group_count'},$results_per_page,$offset, + # because pazGetRecords handles retieving only the records + # we want as specified by $offset and $results_per_page, + # we need to set the offset parameter of searchResults to 0 + my @group_results = searchResults( $query_desc, $group->{'group_count'},$results_per_page, 0, @{ $group->{"RECORDS"} }); push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results }; } -- 2.39.5