Bug #93667: General bug check refactoring.

This commit is contained in:
matty%chariot.net.au 2002-10-05 13:23:44 +00:00
Родитель 69772238fa
Коммит b959ea29a0
1 изменённых файлов: 47 добавлений и 127 удалений

Просмотреть файл

@ -521,152 +521,72 @@ if (exists $::FORM{'rebuildkeywordcache'}) {
} }
########################################################################### ###########################################################################
# Perform duplicates table checks # General bug checks
########################################################################### ###########################################################################
Status("Checking duplicates table"); sub BugCheck ($$) {
my ($middlesql, $errortext) = @_;
SendSQL("SELECT bugs.bug_id " .
"FROM bugs, duplicates " . SendSQL("SELECT DISTINCT bugs.bug_id " .
"WHERE bugs.resolution != 'DUPLICATE' " . "FROM $middlesql " .
" AND bugs.bug_id = duplicates.dupe " . "ORDER BY bugs.bug_id");
"ORDER BY bugs.bug_id");
my @badbugs = ();
@badbugs = ();
while (@row = FetchSQLData()) {
while (@row = FetchSQLData()) { my ($id) = (@row);
my ($id) = (@row); push (@badbugs, $id);
push (@badbugs, $id); }
@badbugs = map(BugLink($_), @badbugs);
if (@badbugs) {
Alert("$errortext: " . join(', ', @badbugs));
}
} }
if (@badbugs) { Status("Checking resolution/duplicates");
Alert("Bug(s) found on duplicates table that are not marked duplicate: " .
join(', ', @badbugs));
}
SendSQL("SELECT bugs.bug_id " . BugCheck("bugs, duplicates WHERE " .
"FROM bugs LEFT JOIN duplicates ON bugs.bug_id = duplicates.dupe " . "bugs.resolution != 'DUPLICATE' AND " .
"WHERE bugs.resolution = 'DUPLICATE' AND duplicates.dupe IS NULL " . "bugs.bug_id = duplicates.dupe",
"ORDER BY bugs.bug_id"); "Bug(s) found on duplicates table that are not marked duplicate");
@badbugs = (); BugCheck("bugs LEFT JOIN duplicates ON bugs.bug_id = duplicates.dupe WHERE " .
"bugs.resolution = 'DUPLICATE' AND " .
while (@row = FetchSQLData()) { "duplicates.dupe IS NULL",
my ($id) = (@row); "Bug(s) found marked resolved duplicate and not on duplicates table");
push (@badbugs, $id);
}
if (@badbugs) {
Alert("Bug(s) found marked resolved duplicate and not on duplicates " .
"table: " . join(', ', @badbugs));
}
###########################################################################
# Perform status/resolution checks
###########################################################################
Status("Checking statuses/resolutions"); Status("Checking statuses/resolutions");
my @open_states = map(SqlQuote($_), OpenStates()); my @open_states = map(SqlQuote($_), OpenStates());
my $open_states = join(', ', @open_states); my $open_states = join(', ', @open_states);
@badbugs = (); BugCheck("bugs WHERE bug_status IN ($open_states) AND resolution != ''",
"Bugs with open status and a resolution");
SendSQL("SELECT bug_id FROM bugs " . BugCheck("bugs WHERE bug_status NOT IN ($open_states) AND resolution = ''",
"WHERE bug_status IN ($open_states) " . "Bugs with non-open status and no resolution");
"AND resolution != '' " .
"ORDER BY bug_id");
while (@row = FetchSQLData()) {
my ($id) = (@row);
push(@badbugs, $id);
}
if (@badbugs > 0) {
Alert("Bugs with open status and a resolution: " .
join (", ", @badbugs));
}
@badbugs = ();
SendSQL("SELECT bug_id FROM bugs " .
"WHERE bug_status NOT IN ($open_states) " .
"AND resolution = '' " .
"ORDER BY bug_id");
while (@row = FetchSQLData()) {
my ($id) = (@row);
push(@badbugs, $id);
}
if (@badbugs > 0) {
Alert("Bugs with non-open status and no resolution: " .
join (", ", @badbugs));
}
###########################################################################
# Perform status/everconfirmed checks
###########################################################################
Status("Checking statuses/everconfirmed"); Status("Checking statuses/everconfirmed");
@badbugs = (); my $sqlunconfirmed = SqlQuote($::unconfirmedstate);
SendSQL("SELECT bug_id FROM bugs " . BugCheck("bugs WHERE bug_status = $sqlunconfirmed AND everconfirmed = 1",
"WHERE bug_status = " . SqlQuote($::unconfirmedstate) . ' ' . "Bugs that are UNCONFIRMED but have everconfirmed set");
"AND everconfirmed = 1 " . # The below list of resolutions is hardcoded because we don't know if future
"ORDER BY bug_id"); # resolutions will be confirmed, unconfirmed or maybeconfirmed. I suspect
# they will be maybeconfirmed, eg ASLEEP and REMIND. This hardcoding should
while (@row = FetchSQLData()) { # disappear when we have customised statuses.
my ($id) = (@row); BugCheck("bugs WHERE bug_status IN ('NEW', 'ASSIGNED', 'REOPENED') AND everconfirmed = 0",
push(@badbugs, $id); "Bugs with confirmed status but don't have everconfirmed set");
}
if (@badbugs > 0) {
Alert("Bugs that are UNCONFIRMED but have everconfirmed set: " .
join (", ", @badbugs));
}
@badbugs = ();
SendSQL("SELECT bug_id FROM bugs " .
"WHERE bug_status IN ('NEW', 'ASSIGNED', 'REOPENED') " .
"AND everconfirmed = 0 " .
"ORDER BY bug_id");
while (@row = FetchSQLData()) {
my ($id) = (@row);
push(@badbugs, $id);
}
if (@badbugs > 0) {
Alert("Bugs with confirmed status but don't have everconfirmed set: " .
join (", ", @badbugs));
}
###########################################################################
# Perform vote/everconfirmed checks
###########################################################################
Status("Checking votes/everconfirmed"); Status("Checking votes/everconfirmed");
@badbugs = (); BugCheck("bugs, products WHERE " .
"bugs.product = products.product AND " .
SendSQL("SELECT bug_id FROM bugs, products " . "everconfirmed = 0 AND " .
"WHERE bugs.product_id = products.id " . "votestoconfirm <= votes",
"AND bug_status = " . SqlQuote($::unconfirmedstate) . ' ' . "Bugs that have enough votes to be confirmed but haven't been");
"AND votestoconfirm <= votes " .
"ORDER BY bug_id");
while (@row = FetchSQLData()) {
my ($id) = (@row);
push(@badbugs, $id);
}
if (@badbugs > 0) {
Alert("Bugs that have enough votes to be confirmed but haven't been: " .
join (", ", @badbugs));
}
########################################################################### ###########################################################################
# Unsent mail # Unsent mail