As caching has evolved, at some point we started returning the entire data set
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Nov 2007 21:49:36 +0000 (21:49 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 9 Nov 2007 21:49:36 +0000 (21:49 +0000)
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

Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/skin/default/js/rresult.js

index d903c90..3daa5f4 100644 (file)
@@ -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 };
 }
 
index c0e150b..e5620af 100644 (file)
@@ -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++ ) {