2000-10-23 21:44:30 +00:00
|
|
|
#!/usr/bonsaitools/bin/perl -w
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Gervase Markham <gerv@gerv.net>
|
|
|
|
#
|
|
|
|
# Generates mostfreq list from data collected by collectstats.pl.
|
|
|
|
|
2001-04-19 17:35:23 +00:00
|
|
|
|
2000-10-23 21:44:30 +00:00
|
|
|
use diagnostics;
|
|
|
|
use strict;
|
|
|
|
use CGI "param";
|
2001-04-06 18:19:47 +00:00
|
|
|
use AnyDBM_File;
|
2000-10-23 21:44:30 +00:00
|
|
|
require "globals.pl";
|
|
|
|
require "CGI.pl";
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
ConnectToDatabase(1);
|
2000-10-23 21:44:30 +00:00
|
|
|
GetVersionTable();
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
my %dbmcount;
|
2000-10-23 21:44:30 +00:00
|
|
|
my %count;
|
|
|
|
my $dobefore = 0;
|
|
|
|
my $before = "";
|
|
|
|
my %before;
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Get params from URL
|
2000-10-23 21:44:30 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
my $changedsince = 7; # default one week
|
|
|
|
my $maxrows = 100; # arbitrary limit on max number of rows
|
|
|
|
my $sortby = "dup_count"; # default to sorting by dup count
|
2000-10-23 21:44:30 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
if (defined(param("sortby")))
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
$sortby = param("sortby");
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check for changedsince param, and see if it's a positive integer
|
2001-03-03 00:17:07 +00:00
|
|
|
if (defined(param("changedsince")) && param("changedsince") =~ /^\d{1,4}$/)
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
$changedsince = param("changedsince");
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
2001-04-06 18:19:47 +00:00
|
|
|
|
|
|
|
# check for max rows param, and see if it's a positive integer
|
|
|
|
if (defined(param("maxrows")) && param("maxrows") =~ /^\d{1,4}$/)
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
$maxrows = param("maxrows");
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Start the page
|
|
|
|
print "Content-type: text/html\n";
|
|
|
|
print "\n";
|
|
|
|
PutHeader("Most Frequently Reported Bugs");
|
2000-10-23 21:44:30 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Open today's record of dupes
|
|
|
|
my $today = &days_ago(0);
|
|
|
|
|
2001-04-19 17:19:07 +00:00
|
|
|
if (<data/duplicates/dupes$today*>)
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-19 17:19:07 +00:00
|
|
|
dbmopen(%dbmcount, "data/duplicates/dupes$today", 0644) ||
|
2001-04-06 18:19:47 +00:00
|
|
|
&die_politely("Can't open today's dupes file: $!");
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
2001-04-06 18:19:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
# Try yesterday's, then (in case today's hasn't been created yet)
|
|
|
|
$today = &days_ago(1);
|
2001-04-19 17:19:07 +00:00
|
|
|
if (<data/duplicates/dupes$today*>)
|
2001-04-06 18:19:47 +00:00
|
|
|
{
|
2001-04-19 17:19:07 +00:00
|
|
|
dbmopen(%dbmcount, "data/duplicates/dupes$today", 0644) ||
|
2001-04-06 18:19:47 +00:00
|
|
|
&die_politely("Can't open yesterday's dupes file: $!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-01 20:17:28 +00:00
|
|
|
&die_politely("There are no duplicate statistics for today ($today) or yesterday.");
|
2001-04-06 18:19:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Copy hash (so we don't mess up the on-disk file when we remove entries)
|
|
|
|
%count = %dbmcount;
|
|
|
|
my $key;
|
|
|
|
my $value;
|
|
|
|
my $threshold = Param("mostfreqthreshold");
|
2000-10-23 21:44:30 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Remove all those dupes under the threshold (for performance reasons)
|
|
|
|
while (($key, $value) = each %count)
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
if ($value < $threshold)
|
|
|
|
{
|
|
|
|
delete $count{$key};
|
|
|
|
}
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Try and open the database from "changedsince" days ago
|
|
|
|
$before = &days_ago($changedsince);
|
|
|
|
|
2001-04-19 17:19:07 +00:00
|
|
|
if (<data/duplicates/dupes$before*>)
|
2001-04-06 18:19:47 +00:00
|
|
|
{
|
2001-04-19 17:19:07 +00:00
|
|
|
dbmopen(%before, "data/duplicates/dupes$before", 0644) && ($dobefore = 1);
|
2001-04-06 18:19:47 +00:00
|
|
|
}
|
2000-10-23 21:44:30 +00:00
|
|
|
|
|
|
|
print Param("mostfreqhtml");
|
|
|
|
|
2001-08-16 02:54:49 +00:00
|
|
|
my $commabugs = join(",", keys(%count));
|
|
|
|
|
2000-10-23 21:44:30 +00:00
|
|
|
print "
|
2001-08-16 02:54:49 +00:00
|
|
|
<p>
|
|
|
|
<a href=\"buglist.cgi?bug_id=$commabugs\">Give me this list as a Bugzilla bug list.</a>
|
|
|
|
</p>
|
|
|
|
|
2000-10-23 21:44:30 +00:00
|
|
|
<table BORDER>
|
|
|
|
<tr BGCOLOR=\"#CCCCCC\">
|
2001-04-06 18:19:47 +00:00
|
|
|
|
|
|
|
<td><center><b>
|
|
|
|
<a href=\"duplicates.cgi?sortby=bug_no&maxrows=$maxrows&changedsince=$changedsince\">Bug #</a>
|
|
|
|
</b></center></td>
|
|
|
|
<td><center><b>
|
|
|
|
<a href=\"duplicates.cgi?sortby=dup_count&maxrows=$maxrows&changedsince=$changedsince\">Dupe<br>Count</a>
|
|
|
|
</b></center></td>\n";
|
|
|
|
|
|
|
|
my %delta;
|
2000-10-23 21:44:30 +00:00
|
|
|
|
|
|
|
if ($dobefore)
|
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
print "<td><center><b>
|
|
|
|
<a href=\"duplicates.cgi?sortby=delta&maxrows=$maxrows&changedsince=$changedsince\">Change in
|
|
|
|
last<br>$changedsince day(s)</a></b></center></td>";
|
|
|
|
|
|
|
|
# Calculate the deltas if we are doing a "before"
|
|
|
|
foreach (keys(%count))
|
|
|
|
{
|
|
|
|
$delta{$_} = $count{$_} - $before{$_};
|
|
|
|
}
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print "
|
|
|
|
<td><center><b>Component</b></center></td>
|
|
|
|
<td><center><b>Severity</b></center></td>
|
|
|
|
<td><center><b>Op Sys</b></center></td>
|
|
|
|
<td><center><b>Target<br>Milestone</b></center></td>
|
|
|
|
<td><center><b>Summary</b></center></td>
|
|
|
|
</tr>\n\n";
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
# Sort, if required
|
|
|
|
my @sortedcount;
|
2000-10-23 21:44:30 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
if ($sortby eq "delta")
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
@sortedcount = sort by_delta keys(%count);
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
2001-04-06 18:19:47 +00:00
|
|
|
elsif ($sortby eq "bug_no")
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-07-01 20:17:28 +00:00
|
|
|
@sortedcount = reverse sort by_bug_no keys(%count);
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
2001-04-06 18:19:47 +00:00
|
|
|
elsif ($sortby eq "dup_count")
|
2000-10-23 21:44:30 +00:00
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
@sortedcount = sort by_dup_count keys(%count);
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
my $i = 0;
|
|
|
|
|
|
|
|
foreach (@sortedcount)
|
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
my $id = $_;
|
2001-08-13 00:19:37 +00:00
|
|
|
SendSQL("SELECT component, bug_severity, op_sys, target_milestone, short_desc, groupset, bug_status, resolution" .
|
2001-03-12 22:35:51 +00:00
|
|
|
" FROM bugs WHERE bug_id = $id");
|
2001-08-13 00:48:45 +00:00
|
|
|
my ($component, $severity, $op_sys, $milestone, $summary, $groupset, $bug_status, $resolution) = FetchSQLData();
|
|
|
|
next unless $groupset == 0;
|
|
|
|
$summary = html_quote($summary);
|
2001-07-01 20:17:28 +00:00
|
|
|
|
2001-08-13 00:19:37 +00:00
|
|
|
# Show all bugs except those CLOSED _OR_ VERIFIED but not INVALID or WONTFIX.
|
|
|
|
# We want to see VERIFIED INVALID and WONTFIX because common "bugs" which aren't
|
|
|
|
# bugs end up in this state.
|
|
|
|
unless ( ($bug_status eq "CLOSED") || ( ($bug_status eq "VERIFIED") &&
|
|
|
|
! ( ($resolution eq "INVALID") || ($resolution eq "WONTFIX") ) ) ) {
|
2001-07-01 20:17:28 +00:00
|
|
|
print "<tr>";
|
|
|
|
print '<td><center>';
|
2001-08-13 00:19:37 +00:00
|
|
|
if ( ($bug_status eq "RESOLVED") || ($bug_status eq "VERIFIED") ) {
|
2001-07-01 20:17:28 +00:00
|
|
|
print "<strike>";
|
|
|
|
}
|
|
|
|
print "<A HREF=\"show_bug.cgi?id=" . $id . "\">";
|
|
|
|
print $id . "</A>";
|
2001-08-13 00:19:37 +00:00
|
|
|
if ( ($bug_status eq "RESOLVED") || ($bug_status eq "VERIFIED") ) {
|
2001-07-01 20:17:28 +00:00
|
|
|
print "</strike>";
|
|
|
|
}
|
|
|
|
print "</center></td>";
|
|
|
|
print "<td><center>$count{$id}</center></td>";
|
|
|
|
if ($dobefore)
|
|
|
|
{
|
|
|
|
print "<td><center>$delta{$id}</center></td>";
|
|
|
|
}
|
|
|
|
print "<td>$component</td>\n ";
|
|
|
|
print "<td><center>$severity</center></td>";
|
|
|
|
print "<td><center>$op_sys</center></td>";
|
|
|
|
print "<td><center>$milestone</center></td>";
|
|
|
|
print "<td>$summary</td>";
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
$i++;
|
2001-04-06 18:19:47 +00:00
|
|
|
}
|
2001-07-01 20:17:28 +00:00
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
if ($i == $maxrows)
|
|
|
|
{
|
|
|
|
last;
|
|
|
|
}
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print "</table><br><br>";
|
|
|
|
PutFooter();
|
|
|
|
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
sub by_bug_no
|
|
|
|
{
|
|
|
|
return ($a <=> $b);
|
|
|
|
}
|
|
|
|
|
2000-10-23 21:44:30 +00:00
|
|
|
sub by_dup_count
|
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
return -($count{$a} <=> $count{$b});
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub by_delta
|
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
return -($delta{$a} <=> $delta{$b});
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub days_ago
|
|
|
|
{
|
2001-04-06 18:19:47 +00:00
|
|
|
my ($dom, $mon, $year) = (localtime(time - ($_[0]*24*60*60)))[3, 4, 5];
|
|
|
|
return sprintf "%04d-%02d-%02d", 1900 + $year, ++$mon, $dom;
|
2000-10-23 21:44:30 +00:00
|
|
|
}
|
|
|
|
|
2001-04-06 18:19:47 +00:00
|
|
|
sub die_politely {
|
|
|
|
my $msg = shift;
|
|
|
|
|
|
|
|
print <<FIN;
|
|
|
|
<p>
|
|
|
|
<table border=1 cellpadding=10>
|
|
|
|
<tr>
|
|
|
|
<td align=center>
|
|
|
|
<font color=blue>$msg</font>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<p>
|
|
|
|
FIN
|
|
|
|
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|