Commit 6ba10a1b authored by gerv%gerv.net's avatar gerv%gerv.net

Whitespace changes only; removing tabs and reformatting my changes to match the…

Whitespace changes only; removing tabs and reformatting my changes to match the rest of the file. Long overdue.
parent 70e7519e
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# #
# Contributor(s): Terry Weissman <terry@mozilla.org>, # Contributor(s): Terry Weissman <terry@mozilla.org>,
# Harrison Page <harrison@netscape.com> # Harrison Page <harrison@netscape.com>
# Gervase Markham <gerv@gerv.net> # Gervase Markham <gerv@gerv.net>
# Run me out of cron at midnight to collect Bugzilla statistics. # Run me out of cron at midnight to collect Bugzilla statistics.
...@@ -33,11 +33,11 @@ require "globals.pl"; ...@@ -33,11 +33,11 @@ require "globals.pl";
# tidy up after graphing module # tidy up after graphing module
if (chdir("graphs")) { if (chdir("graphs")) {
unlink <./*.gif>; unlink <./*.gif>;
unlink <./*.png>; unlink <./*.png>;
chdir(".."); chdir("..");
} }
ConnectToDatabase(1); ConnectToDatabase(1);
GetVersionTable(); GetVersionTable();
...@@ -77,36 +77,38 @@ sub collect_stats { ...@@ -77,36 +77,38 @@ sub collect_stats {
if (open DATA, ">>$file") { if (open DATA, ">>$file") {
push my @row, &today; push my @row, &today;
foreach my $status ('NEW', 'ASSIGNED', 'REOPENED', 'UNCONFIRMED', 'RESOLVED', 'VERIFIED', 'CLOSED') { foreach my $status ('NEW', 'ASSIGNED', 'REOPENED', 'UNCONFIRMED', 'RESOLVED', 'VERIFIED', 'CLOSED') {
if( $product eq "-All-" ) { if( $product eq "-All-" ) {
SendSQL("select count(bug_status) from bugs where bug_status='$status'"); SendSQL("select count(bug_status) from bugs where bug_status='$status'");
} else { } else {
SendSQL("select count(bug_status) from bugs where bug_status='$status' and product='$product'"); SendSQL("select count(bug_status) from bugs where bug_status='$status' and product='$product'");
} }
push @row, FetchOneColumn(); push @row, FetchOneColumn();
} }
foreach my $resolution ('FIXED', 'INVALID', 'WONTFIX', 'LATER', 'REMIND', 'DUPLICATE', 'WORKSFORME', 'MOVED') { foreach my $resolution ('FIXED', 'INVALID', 'WONTFIX', 'LATER', 'REMIND', 'DUPLICATE', 'WORKSFORME', 'MOVED') {
if( $product eq "-All-" ) { if( $product eq "-All-" ) {
SendSQL("select count(resolution) from bugs where resolution='$resolution'"); SendSQL("select count(resolution) from bugs where resolution='$resolution'");
} else { } else {
SendSQL("select count(resolution) from bugs where resolution='$resolution' and product='$product'"); SendSQL("select count(resolution) from bugs where resolution='$resolution' and product='$product'");
} }
push @row, FetchOneColumn();
} push @row, FetchOneColumn();
}
if (! $exists) {
print DATA <<FIN; if (! $exists) {
print DATA <<FIN;
# Bugzilla Daily Bug Stats # Bugzilla Daily Bug Stats
# #
# Do not edit me! This file is generated. # Do not edit me! This file is generated.
# #
# fields: DATE|NEW|ASSIGNED|REOPENED|UNCONFIRMED|RESOLVED|VERIFIED|CLOSED|FIXED|INVALID|WONTFIX|LATER|REMIND|DUPLICATE|WORKSFORME|MOVED # fields: DATE|NEW|ASSIGNED|REOPENED|UNCONFIRMED|RESOLVED|VERIFIED|CLOSED|FIXED|INVALID|WONTFIX|LATER|REMIND|DUPLICATE|WORKSFORME|MOVED
# Product: $product # Product: $product
# Created: $when # Created: $when
FIN FIN
} }
print DATA (join '|', @row) . "\n"; print DATA (join '|', @row) . "\n";
close DATA; close DATA;
} else { } else {
...@@ -128,20 +130,18 @@ sub calculate_dupes { ...@@ -128,20 +130,18 @@ sub calculate_dupes {
# Save % count here in a date-named file # Save % count here in a date-named file
# so we can read it back in to do changed counters # so we can read it back in to do changed counters
# First, delete it if it exists, so we don't add to the contents of an old file # First, delete it if it exists, so we don't add to the contents of an old file
if (-e "data/mining/dupes$today.db") if (-e "data/mining/dupes$today.db") {
{ system("rm -f data/mining/dupes$today.db");
system("rm -f data/mining/dupes$today.db");
} }
dbmopen(%count, "data/mining/dupes$today.db", 0644) || die "Can't open DBM dupes file: $!"; dbmopen(%count, "data/mining/dupes$today.db", 0644) || die "Can't open DBM dupes file: $!";
# Create a hash with key "a bug number", value "bug which that bug is a # Create a hash with key "a bug number", value "bug which that bug is a
# direct dupe of" - straight from the duplicates table. # direct dupe of" - straight from the duplicates table.
while (@row = FetchSQLData()) while (@row = FetchSQLData()) {
{ my $dupe_of = shift @row;
my $dupe_of = shift @row; my $dupe = shift @row;
my $dupe = shift @row; $dupes{$dupe} = $dupe_of;
$dupes{$dupe} = $dupe_of;
} }
# Total up the number of bugs which are dupes of a given bug # Total up the number of bugs which are dupes of a given bug
...@@ -149,46 +149,41 @@ sub calculate_dupes { ...@@ -149,46 +149,41 @@ sub calculate_dupes {
# value = "number of immediate dupes of that bug". # value = "number of immediate dupes of that bug".
foreach $key (keys(%dupes)) foreach $key (keys(%dupes))
{ {
my $dupe_of = $dupes{$key}; my $dupe_of = $dupes{$key};
if (!defined($count{$dupe_of})) if (!defined($count{$dupe_of})) {
{ $count{$dupe_of} = 0;
$count{$dupe_of} = 0; }
}
$count{$dupe_of}++; $count{$dupe_of}++;
} }
# Now we collapse the dupe tree by iterating over %count until # Now we collapse the dupe tree by iterating over %count until
# there is no further change. # there is no further change.
while ($changed == 1) while ($changed == 1)
{ {
$changed = 0; $changed = 0;
foreach $key (keys(%count)) foreach $key (keys(%count)) {
{ # if this bug is actually itself a dupe, and has a count...
# if this bug is actually itself a dupe, and has a count... if (defined($dupes{$key}) && $count{$key} > 0) {
if (defined($dupes{$key}) && $count{$key} > 0) # add that count onto the bug it is a dupe of,
{ # and zero the count; the check is to avoid
# add that count onto the bug it is a dupe of, # loops
# and zero the count; the check is to avoid if ($count{$dupes{$key}} != 0) {
# loops $count{$dupes{$key}} += $count{$key};
if ($count{$dupes{$key}} != 0) $count{$key} = 0;
{ $changed = 1;
$count{$dupes{$key}} += $count{$key}; }
$count{$key} = 0; }
$changed = 1; }
}
}
}
} }
# Remove the values for which the count is zero # Remove the values for which the count is zero
foreach $key (keys(%count)) foreach $key (keys(%count))
{ {
if ($count{$key} == 0) if ($count{$key} == 0) {
{ delete $count{$key};
delete $count{$key}; }
}
} }
dbmclose(%count); dbmclose(%count);
......
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