Commit 7e0c4547 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 151281 - change duplicates.cgi to make one query instead of several…

Bug 151281 - change duplicates.cgi to make one query instead of several thousand. Patch by gerv; r=myk, bbaetz.
parent d5f30d8d
...@@ -110,6 +110,9 @@ my $threshold = Param("mostfreqthreshold"); ...@@ -110,6 +110,9 @@ my $threshold = Param("mostfreqthreshold");
while (my ($key, $value) = each %count) { while (my ($key, $value) = each %count) {
delete $count{$key} if ($value < $threshold); delete $count{$key} if ($value < $threshold);
# If there's a buglist, restrict the bugs to that list.
delete $count{$key} if $sortvisible && (lsearch(\@buglist, $key) == -1);
} }
# Try and open the database from "changedsince" days ago # Try and open the database from "changedsince" days ago
...@@ -135,33 +138,29 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever", ...@@ -135,33 +138,29 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever",
# Don't add CLOSED, and don't add VERIFIED unless they are INVALID or # Don't add CLOSED, and don't add VERIFIED unless they are INVALID or
# WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common # WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common
# "bugs" which aren't bugs end up in this state. # "bugs" which aren't bugs end up in this state.
my $generic_query = " my $query = "
SELECT component, bug_severity, op_sys, target_milestone, SELECT bugs.bug_id, component, bug_severity, op_sys, target_milestone,
short_desc, bug_status, resolution short_desc, bug_status, resolution
FROM bugs FROM bugs
WHERE (bug_status != 'CLOSED') WHERE (bug_status != 'CLOSED')
AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX')) AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX'))
OR (bug_status != 'VERIFIED')) OR (bug_status != 'VERIFIED'))
AND "; AND bugs.bug_id IN (" . join(", ", keys %count) . ")";
# Limit to a single product if requested # Limit to a single product if requested
$generic_query .= (" product = " . SqlQuote($product) . " AND ") if $product; $query .= (" AND product = " . SqlQuote($product)) if $product;
SendSQL(SelectVisible($query,
$userid,
$usergroupset));
my @bugs; my @bugs;
my @bug_ids; my @bug_ids;
my $loop = 0;
foreach my $id (keys(%count)) { while (MoreSQLData()) {
# Maximum row count is dealt with in the template. # Note: maximum row count is dealt with in the template.
# If there's a buglist, restrict the bugs to that list.
next if $sortvisible && $buglist[0] && (lsearch(\@buglist, $id) == -1);
SendSQL(SelectVisible("$generic_query bugs.bug_id = $id",
$userid,
$usergroupset));
next unless MoreSQLData(); my ($id, $component, $bug_severity, $op_sys, $target_milestone,
my ($component, $bug_severity, $op_sys, $target_milestone,
$short_desc, $bug_status, $resolution) = FetchSQLData(); $short_desc, $bug_status, $resolution) = FetchSQLData();
# Limit to open bugs only if requested # Limit to open bugs only if requested
...@@ -178,7 +177,6 @@ foreach my $id (keys(%count)) { ...@@ -178,7 +177,6 @@ foreach my $id (keys(%count)) {
bug_status => $bug_status, bug_status => $bug_status,
resolution => $resolution }); resolution => $resolution });
push (@bug_ids, $id); push (@bug_ids, $id);
$loop++;
} }
$vars->{'bugs'} = \@bugs; $vars->{'bugs'} = \@bugs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment