From 7e0c45474fe5c9c52f77eadb3a8406d95342cfc0 Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Sat, 29 Jun 2002 03:02:09 +0000 Subject: Bug 151281 - change duplicates.cgi to make one query instead of several thousand. Patch by gerv; r=myk, bbaetz. --- duplicates.cgi | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'duplicates.cgi') diff --git a/duplicates.cgi b/duplicates.cgi index 50affa6df..52e611cbf 100755 --- a/duplicates.cgi +++ b/duplicates.cgi @@ -110,6 +110,9 @@ my $threshold = Param("mostfreqthreshold"); while (my ($key, $value) = each %count) { 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 @@ -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 # WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common # "bugs" which aren't bugs end up in this state. -my $generic_query = " - SELECT component, bug_severity, op_sys, target_milestone, +my $query = " + SELECT bugs.bug_id, component, bug_severity, op_sys, target_milestone, short_desc, bug_status, resolution FROM bugs WHERE (bug_status != 'CLOSED') AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX')) OR (bug_status != 'VERIFIED')) - AND "; + AND bugs.bug_id IN (" . join(", ", keys %count) . ")"; # 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 @bug_ids; -my $loop = 0; -foreach my $id (keys(%count)) { - # 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 ($component, $bug_severity, $op_sys, $target_milestone, +while (MoreSQLData()) { + # Note: maximum row count is dealt with in the template. + + my ($id, $component, $bug_severity, $op_sys, $target_milestone, $short_desc, $bug_status, $resolution) = FetchSQLData(); # Limit to open bugs only if requested @@ -178,7 +177,6 @@ foreach my $id (keys(%count)) { bug_status => $bug_status, resolution => $resolution }); push (@bug_ids, $id); - $loop++; } $vars->{'bugs'} = \@bugs; -- cgit v1.2.3-24-g4f1b