Skip to content

Commit

Permalink
Porting SimpleSearch return changes to all code calling it.
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
  • Loading branch information
cnighswonger authored and Joshua Ferraro committed Apr 17, 2008
1 parent 743fbda commit 9b47b82
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion C4/AuthoritiesMarc.pm
Expand Up @@ -802,7 +802,7 @@ sub FindDuplicateAuthority {
# build a request for SearchAuthorities
my $query='at='.$authtypecode.' ';
map {$query.= " and he=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/)} $record->field($auth_tag_to_report)->subfields() if $record->field($auth_tag_to_report);
my ($error,$results)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
my ($error, $results, $total_hits)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
# there is at least 1 result => return the 1st one
if (@$results>0) {
my $marcrecord = MARC::File::USMARC::decode($results->[0]);
Expand Down
4 changes: 2 additions & 2 deletions C4/Heading.pm
Expand Up @@ -119,7 +119,7 @@ sub authorities {
my $self = shift;
my $query = qq(Match-heading,ext="$self->{'search_form'}");
$query .= $self->_query_limiters();
my $results = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
return $results;
}

Expand All @@ -140,7 +140,7 @@ sub preferred_authorities {
my $self = shift;
my $query = "Match-heading-see-from,ext='$self->{'search_form'}'";
$query .= $self->_query_limiters();
my $results = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
my ($error, $results, $total_hits) = SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
return $results;
}

Expand Down
2 changes: 1 addition & 1 deletion C4/Matcher.pm
Expand Up @@ -661,7 +661,7 @@ sub get_matches {
# build query
my $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
# FIXME only searching biblio index at the moment
my ($error, $searchresults) = SimpleSearch($query);
my ($error, $searchresults, $total_hits) = SimpleSearch($query);

warn "search failed ($query) $error" if $error;
foreach my $matched (@$searchresults) {
Expand Down
2 changes: 1 addition & 1 deletion cataloguing/addbiblio.pl
Expand Up @@ -695,7 +695,7 @@ sub BiblioAddAuthorities{
# Search if there is any authorities to link to.
my $query='at='.$data->{authtypecode}.' ';
map {$query.= ' and he,ext="'.$_->[1].'"' if ($_->[0]=~/[A-z]/)} $field->subfields();
my ($error,$results)=SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
my ($error, $results, $total_hits)=SimpleSearch( $query, undef, undef, [ "authorityserver" ] );
# there is only 1 result
if ( $error ) {
warn "BIBLIOADDSAUTHORITIES: $error";
Expand Down
2 changes: 1 addition & 1 deletion cataloguing/addbooks.pl
Expand Up @@ -68,7 +68,7 @@ =head1 cataloguing:addbooks.pl
if ($query) {

# find results
my ( $error, $marcresults ) = SimpleSearch($query);
my ( $error, $marcresults, $total_hits ) = SimpleSearch($query);

if ( defined $error ) {
$template->param( error => $error );
Expand Down
2 changes: 1 addition & 1 deletion cataloguing/value_builder/unimarc_field_4XX.pl
Expand Up @@ -330,7 +330,7 @@ sub plugin {
my $startfrom = $query->param('startfrom');
my $resultsperpage = $query->param('resultsperpage');
my $orderby;
my ( $errors, $results ) = SimpleSearch($search);
my ( $errors, $results, $total_hits ) = SimpleSearch($search);
my $total = scalar(@$results);
$resultsperpage = 20 unless $resultsperpage;

Expand Down
7 changes: 4 additions & 3 deletions labels/label-item-search.pl
Expand Up @@ -58,6 +58,7 @@ BEGIN

my $startfrom = $query->param('startfrom') || 0;
my ( $template, $loggedinuser, $cookie );
my $total_hits;
my (@marclist,@and_or,@excluding,@operator,@value,$orderby,@tags,$results,$total,$error,$marcresults);
# XXX should this be maxItemsInSearchResults or numSearchResults preference instead of 19?
my $resultsperpage = $query->param('resultsperpage') || 19;
Expand All @@ -74,8 +75,7 @@ BEGIN
#catalogsearch( $dbh, \@tags, \@and_or, \@excluding, \@operator, \@value,
# $startfrom * $resultsperpage,
# $resultsperpage, $orderby );
( $error, $marcresults, $total ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage );
warn "\$total=$total";
( $error, $marcresults, $total_hits ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage );
if ($marcresults) {
$show_results = scalar @$marcresults;
} else {
Expand Down Expand Up @@ -150,6 +150,7 @@ BEGIN
}

my @numbers = ();
$total = $total_hits;
if ( $total > $resultsperpage ) {
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
if ( $i < 16 ) {
Expand Down Expand Up @@ -183,7 +184,7 @@ BEGIN
startfromnext => $startfrom + min( $resultsperpage, scalar @results ),
startfromprev => max( $startfrom - $resultsperpage, 0 ),
searchdata => \@field_data,
total => $total,
total => $total_hits,
from => $startfrom + 1,
to => $startfrom + min( $resultsperpage, scalar @results ),
numbers => \@numbers,
Expand Down
2 changes: 1 addition & 1 deletion opac/opac-rss.pl
Expand Up @@ -122,7 +122,7 @@ =head1 SYNOPSIS
);

warn "fetching $size results for $query";
my ( $error, $marcresults ) = SimpleSearch( $query, 0, $size );
my ( $error, $marcresults, $total_hits ) = SimpleSearch( $query, 0, $size );

my $hits = scalar @$marcresults;
my @results;
Expand Down
2 changes: 1 addition & 1 deletion serials/subscription-bib-search.pl
Expand Up @@ -78,7 +78,7 @@ =head1 PARAMETERS
$resultsperpage= $input->param('resultsperpage');
$resultsperpage = 19 if(!defined $resultsperpage);

my ($error,$marcrecords) = SimpleSearch($query);
my ($error, $marcrecords, $total_hits) = SimpleSearch($query);
my $total = scalar @$marcrecords;

if (defined $error) {
Expand Down

0 comments on commit 9b47b82

Please sign in to comment.