Merged revisions 10860-10861 via svnmerge from
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Oct 2008 16:08:14 +0000 (16:08 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Oct 2008 16:08:14 +0000 (16:08 +0000)
svn://svn.open-ils.org/ILS/trunk

........
  r10860 | erickson | 2008-10-17 11:16:18 -0400 (Fri, 17 Oct 2008) | 1 line

  after all search results scanned, we know the exact hit count, so use that instead of the estimated count
........
  r10861 | erickson | 2008-10-17 11:28:11 -0400 (Fri, 17 Oct 2008) | 1 line

  if we have loaded all search results, don't bother estimating the hit count since we know the real hit count already
........

git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@10862 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm

index d2b838e..13432e3 100644 (file)
@@ -800,6 +800,7 @@ sub staged_search {
     my $est_hit_count = 0;
     my $current_page_summary = {};
     my $global_summary = {checked => 0, visible => 0, excluded => 0, deleted => 0, total => 0};
+    my $is_real_hit_count = 0;
 
     for($page = 0; $page < $max_superpages; $page++) {
 
@@ -877,13 +878,18 @@ sub staged_search {
         last if $current_count >= ($user_limit + $user_offset);
 
         # we've scanned all possible hits
-        last if $summary->{checked} < $superpage_size;
+        if($summary->{checked} < $superpage_size) {
+            $est_hit_count = scalar(@$all_results);
+            # we have all possible results in hand, so we know the final hit count
+            $is_real_hit_count = 1;
+            last;
+        }
     }
 
     my @results = grep {defined $_} @$all_results[$user_offset..($user_offset + $user_limit - 1)];
 
        # refine the estimate if we have more than one superpage
-       if ($page > 0) {
+       if ($page > 0 and not $is_real_hit_count) {
                if ($global_summary->{checked} >= $global_summary->{total}) {
                        $est_hit_count = $global_summary->{visible};
                } else {