From 37759414d6fe35b96a66884ca855ada8ef15c2b6 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 9 Nov 2007 21:49:36 +0000 Subject: [PATCH] As caching has evolved, at some point we started returning the entire data set regardless off limit/offset. This patch corrects the post-cache trimming of search results so that it only returns the requested chunk. Also, updated the OPAC so it could understand the data git-svn-id: svn://svn.open-ils.org/ILS/trunk@8051 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Search/Biblio.pm | 30 ++++++++++++---------- Open-ILS/web/opac/skin/default/js/rresult.js | 3 ++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index d903c906fa..3daa5f4545 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -449,6 +449,9 @@ sub the_quest_for_knowledge { return { count => 0 } unless $searchhash and ref $searchhash->{searches} eq 'HASH'; + use Data::Dumper; + warn Dumper($searchhash) . "\n"; + my $method = 'open-ils.storage.biblio.multiclass.search_fts'; my $ismeta = 0; my @recs; @@ -486,6 +489,7 @@ sub the_quest_for_knowledge { $searchhash->{limit} -= $offset; + my $trim = 0; my $result = ($docache) ? search_cache($ckey, $offset, $limit) : undef; if(!$result) { @@ -499,6 +503,7 @@ sub the_quest_for_knowledge { } $result = $U->storagereq( $method, %$searchhash ); + $trim = 1; } else { $docache = 0; @@ -506,29 +511,28 @@ sub the_quest_for_knowledge { return {count => 0} unless ($result && $$result[0]); - #for my $r (@$result) { push(@recs, $r) if ($r and $$r[0]); } @recs = @$result; my $count = ($ismeta) ? $result->[0]->[3] : $result->[0]->[2]; - - if( $docache ) { - + if($docache) { # If we didn't get this data from the cache, put it into the cache # then return the correct offset of records $logger->debug("putting search cache $ckey\n"); put_cache($ckey, $count, \@recs); - - my @t; - for ($offset..$end) { - last unless $recs[$_]; - push(@t, $recs[$_]); - } - @recs = @t; - - #$logger->debug("cache done .. returning $offset..$end : " . OpenSRF::Utils::JSON->perl2JSON(\@recs)); } + if($trim) { + # if we have the full set of data, trim out + # the requested chunk based on limit and offset + my @t; + for ($offset..$end) { + last unless $recs[$_]; + push(@t, $recs[$_]); + } + @recs = @t; + } + return { ids => \@recs, count => $count }; } diff --git a/Open-ILS/web/opac/skin/default/js/rresult.js b/Open-ILS/web/opac/skin/default/js/rresult.js index c0e150bfa4..e5620af463 100644 --- a/Open-ILS/web/opac/skin/default/js/rresult.js +++ b/Open-ILS/web/opac/skin/default/js/rresult.js @@ -252,7 +252,8 @@ function rresultCollectRecords(ids) { runEvt("result", "preCollectRecords"); var x = 0; - var base = getOffset(); + //var base = getOffset(); + var base = 0; if( rresultIsPaged ) base = 0; for( var i = base; i!= getDisplayCount() + base; i++ ) { -- 2.11.0