[open-ils-commits] r8051 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Search web/opac/skin/default/js

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Nov 9 17:05:38 EST 2007


Author: erickson
Date: 2007-11-09 16:49:36 -0500 (Fri, 09 Nov 2007)
New Revision: 8051

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


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




Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2007-11-09 19:47:14 UTC (rev 8050)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm	2007-11-09 21:49:36 UTC (rev 8051)
@@ -449,6 +449,9 @@
 	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 @@
 	$searchhash->{limit} -= $offset;
 
 
+    my $trim = 0;
 	my $result = ($docache) ? search_cache($ckey, $offset, $limit) : undef;
 
 	if(!$result) {
@@ -499,6 +503,7 @@
 		}
 	
 		$result = $U->storagereq( $method, %$searchhash );
+        $trim = 1;
 
 	} else { 
 		$docache = 0; 
@@ -506,29 +511,28 @@
 
 	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;
+    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;
+    }
 
-		#$logger->debug("cache done .. returning $offset..$end : " . OpenSRF::Utils::JSON->perl2JSON(\@recs));
-	}
-
 	return { ids => \@recs, count => $count };
 }
 

Modified: trunk/Open-ILS/web/opac/skin/default/js/rresult.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rresult.js	2007-11-09 19:47:14 UTC (rev 8050)
+++ trunk/Open-ILS/web/opac/skin/default/js/rresult.js	2007-11-09 21:49:36 UTC (rev 8051)
@@ -252,7 +252,8 @@
 	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++ ) {



More information about the open-ils-commits mailing list