]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 632718: Only return 500 search results unless the user specifically
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 2 Mar 2011 08:43:43 +0000 (00:43 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 2 Mar 2011 08:43:43 +0000 (00:43 -0800)
requests to see more.
r=dkl, a=mkanat

Bugzilla/Config/Query.pm
Bugzilla/Search.pm
buglist.cgi
template/en/default/admin/params/query.html.tmpl
template/en/default/list/list.html.tmpl

index 3513b12e30df86340061c7281a3f7ea03f6c0286..17a74998e1ca1950f2fde5fd7c03524fd3966e59 100644 (file)
@@ -73,6 +73,13 @@ sub get_param_list {
    default => 1
   },
 
+  {
+    name => 'default_search_limit',
+    type => 't',
+    default => '500',
+    checker => \&check_numeric
+  },
+
   {
     name => 'max_search_results',
     type => 't',
index edb59e40e01aebc4fd4bcc9ccd9f01559ba3d1fb..81b459ee51ea53181913e6cc46a63fc123a95ae0 100644 (file)
@@ -920,7 +920,7 @@ sub _sql_limit {
         $limit = $max_results;
     }
     
-    if (defined $offset and not defined $limit) {
+    if (defined($offset) && !$limit) {
         $limit = INT_MAX;
     }
     if (defined $limit) {
index 85162ff566b4ce72fc879706fe9b09cf71dc6df5..69c4edaecfa59bba001fe66ec97fd7e0a983f161 100755 (executable)
@@ -776,6 +776,14 @@ if ($fulltext and grep { /^relevance/ } @orderstrings) {
     $vars->{'message'} = 'buglist_sorted_by_relevance'
 }
 
+# In the HTML interface, by default, we limit the returned results,
+# which speeds up quite a few searches where people are really only looking
+# for the top results.
+if ($format->{'extension'} eq 'html' && !defined $cgi->param('limit')) {
+    $params->param('limit', Bugzilla->params->{'default_search_limit'});
+    $vars->{'default_limited'} = 1;
+}
+
 # Generate the basic SQL query that will be used to generate the bug list.
 my $search = new Bugzilla::Search('fields' => \@selectcolumns, 
                                   'params' => scalar $params->Vars,
@@ -783,6 +791,9 @@ my $search = new Bugzilla::Search('fields' => \@selectcolumns,
 my $query = $search->sql;
 $vars->{'search_description'} = $search->search_description;
 
+# We don't want saved searches and other buglist things to save
+# our default limit.
+$params->delete('limit') if $vars->{'default_limited'};
 
 ################################################################################
 # Query Execution
index 0c0ff6224bb784494a3a53db8421cc1a7bc947ff..d8f5f0c421b7a5f35b826313e72abe769d368b25 100644 (file)
     "Whether to allow a search on the 'Simple Search' page with an empty"
     _ " 'Words' field.",
 
+  default_search_limit =>
+    "By default, $terms.Bugzilla limits searches done in the web"
+    _ " interface to returning only this many results, for performance"
+    _ " reasons. (This only affects the HTML format of search results--CSV,"
+    _ " XML, and other formats are exempted.) Users can click a link on the"
+    _ " search result page to see all the results."
+    _ "<p>Usually you should not have to change this--the default value"
+    _ " should be acceptable for almost most installations.</p>",
+
   max_search_results =>
     "The maximum number of $terms.bugs that a search can"
     _ " <strong>ever</strong> return. Tabular and graphical reports"
-    _ " are exempted from this limit, however."
+    _ " are exempted from this limit, however.",
 
 } %]
index a669aecb928c4a9791f4db11f3b4015709883252..15184d06bde19f910e26f765ee6245bfff2fa1c8 100644 (file)
 [%############################################################################%]
 
 [% IF bugs.size > 9 %]
-  <span class="bz_result_count">
-    [% bugs.size %] [%+ terms.bugs %] found.
-  </span>
+  [% PROCESS num_results %]
 [% END %]
 
 [%############################################################################%]
 [%# Succeeding Status Line                                                   #%]
 [%############################################################################%]
 
-<span class="bz_result_count">
-  [% IF bugs.size == 0 %]
-    <span class="zero_results">[% terms.zeroSearchResults %].</span>
-  [% ELSIF bugs.size == 1 %]
-    One [% terms.bug %] found.
-  [% ELSE %]
-    [% bugs.size %] [%+ terms.bugs %] found.
-  [% END %]
-</span>
+[% PROCESS num_results %]
 
 [% IF bugs.size == 0 %]
   <ul class="zero_result_links">
 
 [% PROCESS global/footer.html.tmpl %]
 
+[%##########%]
+[%# Blocks #%]
+[%##########%]
+
 [% BLOCK edit_search_url %]
   [% editqueryname = searchname OR defaultsavename OR '' %]
   query.cgi?[% urlquerypart FILTER html %]
      in the "[% one_product.name FILTER html %]" product
    [% END %]</a>
 [% END %]
+
+[% BLOCK num_results %]
+  <span class="bz_result_count">
+    [% IF bugs.size == 0 %]
+      <span class="zero_results">[% terms.zeroSearchResults %].</span>
+    [% ELSIF default_limited AND bugs.size >= Param('default_search_limit') %]
+      This result was limited to [% Param('default_search_limit') FILTER html %]
+      [%+ terms.bugs %].
+      <a href="buglist.cgi?[% urlquerypart FILTER html %]
+              [%- "&order=$qorder" FILTER html IF order %]&limit=0">See
+        all search results for this query</a>.
+    [% ELSIF bugs.size == 1 %]
+      One [% terms.bug %] found.
+    [% ELSE %]
+      [% bugs.size %] [%+ terms.bugs %] found.
+    [% END %]
+  </span>
+[% END %]