if we have loaded all search results, don't bother estimating the hit count since...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Oct 2008 15:28:11 +0000 (15:28 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Oct 2008 15:28:11 +0000 (15:28 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10861 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index ce19988..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++) {
 
@@ -879,6 +880,8 @@ sub staged_search {
         # we've scanned all possible hits
         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;
         }
     }
@@ -886,7 +889,7 @@ sub staged_search {
     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 {