1998-10-18 22:18:25 +00:00
#!/usr/bonsaitools/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
1999-11-01 23:33:56 +00:00
# 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/
1998-10-18 22:18:25 +00:00
#
1999-11-01 23:33:56 +00:00
# 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.
1998-10-18 22:18:25 +00:00
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
1999-11-01 23:33:56 +00:00
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
1998-10-18 22:18:25 +00:00
#
# Contributor(s): Harrison Page <harrison@netscape.com>,
1999-05-04 00:01:57 +00:00
# Terry Weissman <terry@mozilla.org>,
1999-08-05 20:02:20 +00:00
# Dawn Endico <endico@mozilla.org>
# Bryce Nesbitt <bryce@nextbus.COM>,
# Added -All- report, change "nobanner" to "banner" (it is strange to have a
# list with 2 positive and 1 negative choice), default links on, add show
# sql comment.
2000-07-21 17:00:40 +00:00
# Joe Robins <jmrobins@tgix.com>,
# If using the usebuggroups parameter, users shouldn't be able to see
# reports for products they don't have access to.
2000-10-30 23:02:41 +00:00
# Gervase Markham <gerv@gerv.net> and Adam Spiers <adam@spiers.net>
# Added ability to chart any combination of resolutions/statuses.
# Derive the choice of resolutions/statuses from the -All- data file
# Removed hardcoded order of resolutions/statuses when reading from
# daily stats file, so now works independently of collectstats.pl
# version
# Added image caching by date and datasets
1998-10-18 22:18:25 +00:00
use diagnostics;
use strict;
2000-10-30 23:02:41 +00:00
2001-01-20 16:58:32 +00:00
eval "use GD";
my $use_gd = @ ? 0 : 1;
1999-09-29 22:51:30 +00:00
eval "use Chart::Lines";
2001-01-20 16:58:32 +00:00
$use_gd = 0 if $@;
1998-10-18 22:18:25 +00:00
require "CGI.pl";
2000-10-30 23:02:41 +00:00
use vars qw(%FORM); # globals from CGI.pl
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
require "globals.pl";
use vars qw(@legal_product); # globals from er, globals.pl
1998-10-18 22:18:25 +00:00
1998-10-26 20:15:13 +00:00
my $dir = "data/mining";
2000-12-05 22:36:26 +00:00
my $graph_dir = "graphs";
2000-10-30 23:02:41 +00:00
1998-10-18 22:18:25 +00:00
my @status = qw (NEW ASSIGNED REOPENED);
1999-08-05 20:02:20 +00:00
my %bugsperperson;
1998-10-18 22:18:25 +00:00
1998-10-26 20:15:13 +00:00
# while this looks odd/redundant, it allows us to name
# functions differently than the value passed in
1998-10-18 22:18:25 +00:00
1998-10-26 20:15:13 +00:00
my %reports =
2000-10-30 23:02:41 +00:00
(
"most_doomed" => \&most_doomed,
"most_doomed_for_milestone" => \&most_doomed_for_milestone,
"most_recently_doomed" => \&most_recently_doomed,
"show_chart" => \&show_chart,
);
1998-10-26 20:15:13 +00:00
2000-07-21 17:00:40 +00:00
# If we're using bug groups for products, we should apply those restrictions
# to viewing reports, as well. Time to check the login in that case.
2000-10-25 02:34:13 +00:00
ConnectToDatabase(1);
2000-07-21 17:00:40 +00:00
quietly_check_login();
2000-07-19 16:05:52 +00:00
print "Content-type: text/html\n";
2000-08-07 22:59:55 +00:00
#Changing attachment to inline to resolve 46897
#zach@zachlipton.com
print "Content-disposition: inline; filename=bugzilla_report.html\n\n";
1998-10-26 20:15:13 +00:00
1999-05-04 00:01:57 +00:00
# If we're here for the first time, give a banner. Else respect the banner flag.
2000-10-30 23:02:41 +00:00
if ( (!defined $FORM{'product'}) || ($FORM{'banner'}) ) {
PutHeader ("Bug Reports")
}
else {
print("<html><head><title>Bug Reports</title></head><body bgcolor=\"#FFFFFF\">");
}
1998-10-26 20:15:13 +00:00
1998-10-27 10:43:01 +00:00
GetVersionTable();
1998-10-18 22:18:25 +00:00
2000-07-21 17:00:40 +00:00
# If the usebuggroups parameter is set, we don't want to list all products.
# We only want those products that the user has permissions for.
1999-05-04 00:01:57 +00:00
my @myproducts;
2000-07-21 17:00:40 +00:00
if(Param("usebuggroups")) {
2000-10-30 23:02:41 +00:00
push( @myproducts, "-All-");
foreach my $this_product (@legal_product) {
if(GroupExists($this_product) && !UserInGroup($this_product)) {
next;
} else {
push( @myproducts, $this_product )
}
2000-07-21 17:00:40 +00:00
}
} else {
2000-10-30 23:02:41 +00:00
push( @myproducts, "-All-", @legal_product );
2000-07-21 17:00:40 +00:00
}
1999-05-04 00:01:57 +00:00
2000-10-30 23:02:41 +00:00
$FORM{'output'} ||= "most_doomed"; # a reasonable default
if (! defined $FORM{'product'}) {
&choose_product;
}
else {
# If usebuggroups is on, we don't want people to be able to view
# reports for products they don't have permissions for...
if(Param("usebuggroups") &&
GroupExists($FORM{'product'}) &&
!UserInGroup($FORM{'product'}))
{
print "<H1>Permission denied.</H1>\n";
print "Sorry; you do not have the permissions necessary to view\n";
print "reports for this product.\n";
print "<P>\n";
PutFooter();
exit;
}
2000-07-21 17:00:40 +00:00
2000-10-30 23:02:41 +00:00
# we want to be careful about what subroutines
# can be called from outside. modify %reports
# accordingly when a new report type is added
if (! exists $reports{$FORM{'output'}}) {
$FORM{'output'} = "most_doomed"; # a reasonable default
}
my $f = $reports{$FORM{'output'}};
if (! defined $f) {
print "start over, your form data was all messed up.<p>\n";
foreach (keys %::FORM) {
print "<font color=blue>$_</font> : " .
($FORM{$_} ? $FORM{$_} : "undef") . "<br>\n";
}
PutFooter() if $FORM{banner};
exit;
}
&{$f};
}
1998-10-18 22:18:25 +00:00
print <<FIN;
<p>
FIN
2000-10-30 23:02:41 +00:00
PutFooter() if $FORM{banner};
2000-01-19 20:30:28 +00:00
2000-01-14 22:35:49 +00:00
1998-10-18 22:18:25 +00:00
##################################
# user came in with no form data #
##################################
2000-10-30 23:02:41 +00:00
sub choose_product {
my $product_popup = make_options (\@myproducts, $myproducts[0]);
2001-01-20 16:58:32 +00:00
my $charts = $use_gd && -d $dir ? "<option value=\"show_chart\">Bug Charts" : "";
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print <<FIN;
1998-10-18 22:18:25 +00:00
<center>
<h1>Welcome to the Bugzilla Query Kitchen</h1>
<form method=get action=reports.cgi>
<table border=1 cellpadding=5>
<tr>
<td align=center><b>Product:</b></td>
<td align=center>
<select name="product">
$product_popup
</select>
</td>
</tr>
<tr>
1998-10-26 20:15:13 +00:00
<td align=center><b>Output:</b></td>
<td align=center>
<select name="output">
<option value="most_doomed">Bug Counts
1999-08-05 20:48:51 +00:00
FIN
2000-10-30 23:02:41 +00:00
if (Param('usetargetmilestone')) {
print "<option value=\"most_doomed_for_milestone\">Most Doomed";
}
print "<option value=\"most_recently_doomed\">Most Recently Doomed";
print <<FIN;
1998-10-27 10:43:01 +00:00
$charts
1998-10-26 20:15:13 +00:00
</select>
<tr>
2000-10-30 23:02:41 +00:00
<td align=center><b>Chart datasets:</b></td>
<td align=center>
<select name="datasets" multiple size=5>
FIN
my @datasets = ();
my $datafile = daily_stats_filename('-All-');
if (! open(DATA, "$dir/$datafile")) {
die_politely("Couldn't read daily statistics file");
}
while (<DATA>) {
if (/^# fields?: (.+)\s*$/) {
@datasets = grep ! /date/i, (split /\|/, $1);
last;
}
}
close(DATA);
my %default_sel = map { $_ => 1 }
qw/UNCONFIRMED NEW ASSIGNED REOPENED/;
foreach my $dataset (@datasets) {
my $sel = $default_sel{$dataset} ? ' selected' : '';
print qq{<option value="$dataset:"$sel>$dataset</option>\n};
}
print <<FIN;
</select>
</td>
</tr>
<tr>
1998-10-18 22:18:25 +00:00
<td align=center><b>Switches:</b></td>
<td align=left>
1999-05-04 00:01:57 +00:00
<input type=checkbox name=links checked value=1> Links to Bugs<br>
<input type=checkbox name=banner checked value=1> Banner<br>
1999-09-27 21:25:19 +00:00
FIN
2000-10-30 23:02:41 +00:00
if (Param('usequip')) {
print "<input type=checkbox name=quip value=1> Quip<br>";
} else {
print "<input type=hidden name=quip value=0>";
}
print <<FIN;
1998-10-18 22:18:25 +00:00
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=submit value=Continue>
</td>
</tr>
</table>
</form>
<p>
FIN
1999-05-04 00:01:57 +00:00
#Add this above to get a control for showing the SQL query:
#<input type=checkbox name=showsql value=1> Show SQL<br>
2000-10-30 23:02:41 +00:00
PutFooter();
}
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
sub most_doomed {
my $when = localtime (time);
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print <<FIN;
1998-10-18 22:18:25 +00:00
<center>
<h1>
2000-10-30 23:02:41 +00:00
Bug Report for $FORM{'product'}
1998-10-18 22:18:25 +00:00
</h1>
$when<p>
FIN
1999-05-04 00:01:57 +00:00
# Build up $query string
2000-10-30 23:02:41 +00:00
my $query;
$query = <<FIN;
1998-10-18 22:18:25 +00:00
select
2000-10-30 23:02:41 +00:00
bugs.bug_id, bugs.assigned_to, bugs.bug_severity,
bugs.bug_status, bugs.product,
assign.login_name,
report.login_name,
unix_timestamp(date_format(bugs.creation_ts, '%Y-%m-%d %h:%m:%s'))
1998-10-18 22:18:25 +00:00
from bugs,
profiles assign,
profiles report,
versions projector
where bugs.assigned_to = assign.userid
and bugs.reporter = report.userid
1999-05-04 00:01:57 +00:00
FIN
2000-10-30 23:02:41 +00:00
if ($FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product=".SqlQuote($FORM{'product'});
}
$query .= <<FIN;
and
(
bugs.bug_status = 'NEW' or
bugs.bug_status = 'ASSIGNED' or
bugs.bug_status = 'REOPENED'
)
1998-10-18 22:18:25 +00:00
FIN
1999-05-04 00:01:57 +00:00
# End build up $query string
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print "<font color=purple><tt>$query</tt></font><p>\n"
unless (! exists $FORM{'showsql'});
SendSQL ($query);
my $c = 0;
my $quip = "Summary";
my $bugs_count = 0;
my $bugs_new_this_week = 0;
my $bugs_reopened = 0;
my %bugs_owners;
my %bugs_summary;
my %bugs_status;
my %bugs_totals;
my %bugs_lookup;
#############################
# suck contents of database #
#############################
my $week = 60 * 60 * 24 * 7;
while (my ($bid, $a, $sev, $st, $prod, $who, $rep, $ts) = FetchSQLData()) {
next if (exists $bugs_lookup{$bid});
$bugs_lookup{$bid} ++;
$bugs_owners{$who} ++;
$bugs_new_this_week ++ if (time - $ts <= $week);
$bugs_status{$st} ++;
$bugs_count ++;
push @{$bugs_summary{$who}{$st}}, $bid;
$bugs_totals{$who}{$st} ++;
}
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
}
close COMMENTS;
$quip = "<i>" . $cdata[int(rand($#cdata + 1))] . "</i>";
}
}
#########################
# start painting report #
#########################
$bugs_status{'NEW'} ||= '0';
$bugs_status{'ASSIGNED'} ||= '0';
$bugs_status{'REOPENED'} ||= '0';
print <<FIN;
1998-10-27 10:43:01 +00:00
<h1>$quip</h1>
1998-10-18 22:18:25 +00:00
<table border=1 cellpadding=5>
<tr>
<td align=right><b>New Bugs This Week</b></td>
<td align=center>$bugs_new_this_week</td>
</tr>
<tr>
<td align=right><b>Bugs Marked New</b></td>
<td align=center>$bugs_status{'NEW'}</td>
</tr>
<tr>
<td align=right><b>Bugs Marked Assigned</b></td>
<td align=center>$bugs_status{'ASSIGNED'}</td>
</tr>
<tr>
<td align=right><b>Bugs Marked Reopened</b></td>
<td align=center>$bugs_status{'REOPENED'}</td>
</tr>
<tr>
<td align=right><b>Total Bugs</b></td>
<td align=center>$bugs_count</td>
</tr>
</table>
<p>
FIN
2000-10-30 23:02:41 +00:00
if ($bugs_count == 0) {
print "No bugs found!\n";
PutFooter() if $FORM{banner};
exit;
}
print <<FIN;
1998-10-18 22:18:25 +00:00
<h1>Bug Count by Engineer</h1>
<table border=3 cellpadding=5>
<tr>
<td align=center bgcolor="#DDDDDD"><b>Owner</b></td>
<td align=center bgcolor="#DDDDDD"><b>New</b></td>
<td align=center bgcolor="#DDDDDD"><b>Assigned</b></td>
<td align=center bgcolor="#DDDDDD"><b>Reopened</b></td>
<td align=center bgcolor="#DDDDDD"><b>Total</b></td>
</tr>
FIN
2000-10-30 23:02:41 +00:00
foreach my $who (sort keys %bugs_summary) {
my $bugz = 0;
print <<FIN;
1998-10-18 22:18:25 +00:00
<tr>
<td align=left><tt>$who</tt></td>
FIN
2000-10-30 23:02:41 +00:00
foreach my $st (@status) {
$bugs_totals{$who}{$st} += 0;
print <<FIN;
1998-10-18 22:18:25 +00:00
<td align=center>$bugs_totals{$who}{$st}
FIN
2000-10-30 23:02:41 +00:00
$bugz += $#{$bugs_summary{$who}{$st}} + 1;
}
print <<FIN;
1998-10-18 22:18:25 +00:00
<td align=center>$bugz</td>
</tr>
FIN
2000-10-30 23:02:41 +00:00
}
print <<FIN;
1998-10-18 22:18:25 +00:00
</table>
<p>
FIN
2000-10-30 23:02:41 +00:00
###############################
# individual bugs by engineer #
###############################
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print <<FIN;
1998-10-18 22:18:25 +00:00
<h1>Individual Bugs by Engineer</h1>
<table border=1 cellpadding=5>
<tr>
<td align=center bgcolor="#DDDDDD"><b>Owner</b></td>
<td align=center bgcolor="#DDDDDD"><b>New</b></td>
<td align=center bgcolor="#DDDDDD"><b>Assigned</b></td>
<td align=center bgcolor="#DDDDDD"><b>Reopened</b></td>
</tr>
FIN
2000-10-30 23:02:41 +00:00
foreach my $who (sort keys %bugs_summary) {
print <<FIN;
1998-10-18 22:18:25 +00:00
<tr>
<td align=left><tt>$who</tt></td>
FIN
2000-10-30 23:02:41 +00:00
foreach my $st (@status) {
my @l;
foreach (sort { $a <=> $b } @{$bugs_summary{$who}{$st}}) {
if ($FORM{'links'}) {
push @l, "<a href=\"show_bug.cgi?id=$_\">$_</a>\n";
}
else {
push @l, $_;
}
}
my $bugz = join ' ', @l;
$bugz = " " unless ($bugz);
print <<FIN
1998-10-18 22:18:25 +00:00
<td align=left>$bugz</td>
FIN
2000-10-30 23:02:41 +00:00
}
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print <<FIN;
1998-10-18 22:18:25 +00:00
</tr>
FIN
2000-10-30 23:02:41 +00:00
}
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
print <<FIN;
1998-10-18 22:18:25 +00:00
</table>
<p>
FIN
2000-10-30 23:02:41 +00:00
}
1998-10-18 22:18:25 +00:00
2000-10-30 23:02:41 +00:00
sub is_legal_product {
my $product = shift;
return grep { $_ eq $product} @myproducts;
}
1998-10-27 10:43:01 +00:00
2000-10-30 23:02:41 +00:00
sub daily_stats_filename {
my ($prodname) = @_;
$prodname =~ s/\//-/gs;
return $prodname;
}
1998-10-26 20:15:13 +00:00
2000-10-30 23:02:41 +00:00
sub show_chart {
2001-01-20 16:58:32 +00:00
# if we don't have the graphic mouldes don't even try to go
# here. Should probably return some decent error message.
return unless $use_gd;
2000-10-30 23:02:41 +00:00
if (! is_legal_product ($FORM{'product'})) {
&die_politely ("Unknown product: $FORM{'product'}");
}
if (! $FORM{datasets}) {
die_politely("You didn't select any datasets to plot");
}
1998-10-27 10:43:01 +00:00
1998-10-26 20:15:13 +00:00
print <<FIN;
<center>
FIN
2000-10-30 23:02:41 +00:00
my $type = chart_image_type();
my $data_file = daily_stats_filename($FORM{product});
my $image_file = chart_image_name($data_file, $type);
2000-12-05 22:36:26 +00:00
my $url_image = "$graph_dir/" . url_quote($image_file);
2000-10-30 23:02:41 +00:00
2000-12-05 22:36:26 +00:00
if (! -e "$graph_dir/$image_file") {
generate_chart("$dir/$data_file", "$graph_dir/$image_file", $type);
2000-10-30 23:02:41 +00:00
}
print <<FIN;
2000-04-25 21:05:32 +00:00
<img src="$url_image">
1998-10-26 20:15:13 +00:00
<br clear=left>
<br>
FIN
2000-10-30 23:02:41 +00:00
}
1998-10-26 20:15:13 +00:00
2000-10-30 23:02:41 +00:00
sub chart_image_type {
# what chart type should we be generating?
my $testimg = Chart::Lines->new(2,2);
2001-01-20 16:58:32 +00:00
eval '$testimg->gif()';
2000-10-30 23:02:41 +00:00
my $type = $testimg->can('gif') ? "gif" : "png";
2001-01-20 16:58:32 +00:00
2000-10-30 23:02:41 +00:00
undef $testimg;
return $type;
}
1998-10-26 20:15:13 +00:00
2000-10-30 23:02:41 +00:00
sub chart_image_name {
my ($data_file, $type) = @_;
my $id = datasets_id($FORM{datasets});
my $doy = day_of_year();
return "${data_file}_${id}.$type";
}
# Cache charts by generating a unique filename based on what they
# show. Charts should be deleted by collectstats.pl nightly.
sub datasets_id {
# Current method is very long filenames...
my $longname = "";
foreach (@_) {
$longname .= $_;
}
return $longname;
}
sub day_of_year {
my ($mday, $month, $year) = (localtime())[3 .. 5];
$month += 1;
$year += 1900;
my $date = sprintf "%02d%02d%04d", $mday, $month, $year;
}
sub generate_chart {
my ($data_file, $image_file, $type) = @_;
if (! open FILE, $data_file) {
&die_politely ("The tool which gathers bug counts has not been run yet.");
}
my @fields;
my @labels = qw(DATE);
my %datasets = map { $_ => 1 } split /:/, $FORM{datasets};
my %data = ();
while (<FILE>) {
chomp;
next unless $_;
if (/^#/) {
if (/^# fields?: (.*)\s*$/) {
2001-01-18 23:08:22 +00:00
@fields = split /\||\r/, $1;
2000-10-30 23:02:41 +00:00
&die_politely("`# fields: ' line didn't start with DATE, but with $fields[0]")
unless $fields[0] =~ /date/i;
push @labels, grep($datasets{$_}, @fields);
}
next;
}
&die_politely("`# fields: ' line was not found before start of data")
unless @fields;
my @line = split /\|/;
my $date = $line[0];
my ($yy, $mm, $dd) = $date =~ /^\d{2}(\d{2})(\d{2})(\d{2})$/;
push @{$data{DATE}}, "$mm/$dd/$yy";
for my $i (1 .. $#fields) {
my $field = $fields[$i];
if (! defined $line[$i] or $line[$i] eq '') {
# no data point given, don't plot (this will probably
# generate loads of Chart::Base warnings, but that's not
2000-12-05 22:36:26 +00:00
# our fault.)
2000-10-30 23:02:41 +00:00
push @{$data{$field}}, undef;
}
else {
push @{$data{$field}}, $line[$i];
}
}
}
shift @labels;
close FILE;
if (! @{$data{DATE}}) {
&die_politely ("We don't have enough data points to make a graph (yet)");
}
my $img = Chart::Lines->new (800, 600);
my $i = 0;
my $MAXTICKS = 20; # Try not to show any more x ticks than this.
my $skip = 1;
if (@{$data{DATE}} > $MAXTICKS) {
$skip = int((@{$data{DATE}} + $MAXTICKS - 1) / $MAXTICKS);
}
my %settings =
(
"title" => "Status Counts for $FORM{'product'}",
"x_label" => "Dates",
"y_label" => "Bug Counts",
"legend_labels" => \@labels,
"skip_x_ticks" => $skip,
"y_grid_lines" => "true",
"grey_background" => "false",
"colors" => {
# default dataset colours are too alike
dataset4 => [0, 0, 0], # black
},
);
$img->set (%settings);
$img->$type($image_file, [ @data{('DATE', @labels)} ]);
}
sub die_politely {
my $msg = shift;
print <<FIN;
1998-10-26 20:15:13 +00:00
<p>
<table border=1 cellpadding=10>
<tr>
<td align=center>
<font color=blue>Sorry, but ...</font>
<p>
2000-10-30 23:02:41 +00:00
There is no graph available for <b>$FORM{'product'}</b><p>
1998-10-26 20:15:13 +00:00
$msg
<p>
</td>
</tr>
</table>
<p>
FIN
2000-10-30 23:02:41 +00:00
PutFooter() if $FORM{banner};
exit;
}
1998-10-26 20:15:13 +00:00
1999-08-07 00:38:09 +00:00
sub bybugs {
$bugsperperson{$a} <=> $bugsperperson{$b}
2000-10-30 23:02:41 +00:00
}
1998-10-26 20:15:13 +00:00
2000-10-30 23:02:41 +00:00
sub most_doomed_for_milestone {
my $when = localtime (time);
my $ms = "M" . Param("curmilestone");
my $quip = "Summary";
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
print "<center>\n<h1>";
if( $FORM{'product'} ne "-All-" ) {
2000-11-09 18:57:51 +00:00
SendSQL("SELECT defaultmilestone FROM products WHERE product = " .
SqlQuote($FORM{'product'}));
$ms = FetchOneColumn();
2000-10-30 23:02:41 +00:00
print "Most Doomed for $ms ($FORM{'product'})";
} else {
print "Most Doomed for $ms";
}
print "</h1>\n$when<p>\n";
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
#########################
# start painting report #
#########################
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
}
close COMMENTS;
$quip = "<i>" . $cdata[int(rand($#cdata + 1))] . "</i>";
}
}
# Build up $query string
my $query;
$query = "select distinct assigned_to from bugs where target_milestone=\"$ms\"";
if ($FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product=".SqlQuote($FORM{'product'});
}
$query .= <<FIN;
and
(
bugs.bug_status = 'NEW' or
bugs.bug_status = 'ASSIGNED' or
bugs.bug_status = 'REOPENED'
)
1999-08-05 20:02:20 +00:00
FIN
# End build up $query string
2000-10-30 23:02:41 +00:00
SendSQL ($query);
my @people = ();
while (my ($person) = FetchSQLData()) {
push @people, $person;
}
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
#############################
# suck contents of database #
#############################
my $person = "";
my $bugtotal = 0;
foreach $person (@people) {
my $query = "select count(bug_id) from bugs,profiles where target_milestone=\"$ms\" and userid=assigned_to and userid=\"$person\"";
if( $FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product=".SqlQuote($FORM{'product'});
}
$query .= <<FIN;
and
(
bugs.bug_status = 'NEW' or
bugs.bug_status = 'ASSIGNED' or
bugs.bug_status = 'REOPENED'
)
1999-08-05 21:21:01 +00:00
FIN
2000-10-30 23:02:41 +00:00
SendSQL ($query);
my $bugcount = FetchSQLData();
$bugsperperson{$person} = $bugcount;
$bugtotal += $bugcount;
}
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
# sort people by the number of bugs they have assigned to this milestone
@people = sort bybugs @people;
my $totalpeople = @people;
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
print "<TABLE>\n";
print "<TR><TD COLSPAN=2>\n";
print "$totalpeople engineers have $bugtotal $ms bugs and features.\n";
print "</TD></TR>\n";
while (@people) {
$person = pop @people;
print "<TR><TD>\n";
SendSQL("select login_name from profiles where userid=$person");
my $login_name= FetchSQLData();
print("<A HREF=\"buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&target_milestone=$ms&assigned_to=$login_name");
if ($FORM{'product'} ne "-All-" ) {
print "&product=" . url_quote($FORM{'product'});
}
print("\">\n");
print("$bugsperperson{$person} bugs and features");
print("</A>");
print(" for \n");
print("<A HREF=\"mailto:$login_name\">");
print("$login_name");
print("</A>\n");
print("</TD><TD>\n");
$person = pop @people;
if ($person) {
SendSQL("select login_name from profiles where userid=$person");
my $login_name= FetchSQLData();
print("<A HREF=\"buglist.cgi?bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&target_milestone=$ms&assigned_to=$login_name\">\n");
print("$bugsperperson{$person} bugs and features");
print("</A>");
print(" for \n");
print("<A HREF=\"mailto:$login_name\">");
print("$login_name");
print("</A>\n");
print("</TD></TR>\n\n");
1999-08-05 20:02:20 +00:00
}
2000-10-30 23:02:41 +00:00
}
print "</TABLE>\n";
}
1999-08-05 20:02:20 +00:00
2000-10-30 23:02:41 +00:00
sub most_recently_doomed {
my $when = localtime (time);
my $ms = "M" . Param("curmilestone");
my $quip = "Summary";
print "<center>\n<h1>";
if( $FORM{'product'} ne "-All-" ) {
2000-11-09 18:57:51 +00:00
SendSQL("SELECT defaultmilestone FROM products WHERE product = " .
SqlQuote($FORM{'product'}));
$ms = FetchOneColumn();
2000-10-30 23:02:41 +00:00
print "Most Recently Doomed ($FORM{'product'})";
} else {
print "Most Recently Doomed";
}
print "</h1>\n$when<p>\n";
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
#########################
# start painting report #
#########################
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
if ($FORM{'quip'}) {
if (open (COMMENTS, "<data/comments")) {
my @cdata;
while (<COMMENTS>) {
push @cdata, $_;
1999-08-07 00:38:09 +00:00
}
2000-10-30 23:02:41 +00:00
close COMMENTS;
$quip = "<i>" . $cdata[int(rand($#cdata + 1))] . "</i>";
}
}
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
# Build up $query string
my $query = "select distinct assigned_to from bugs where bugs.bug_status='NEW' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')";
if ($FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product=".SqlQuote($FORM{'product'});
}
1999-08-07 00:38:09 +00:00
# End build up $query string
2000-10-30 23:02:41 +00:00
SendSQL ($query);
my @people = ();
while (my ($person) = FetchSQLData()) {
push @people, $person;
}
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
#############################
# suck contents of database #
#############################
my $person = "";
my $bugtotal = 0;
foreach $person (@people) {
my $query = "select count(bug_id) from bugs,profiles where bugs.bug_status='NEW' and userid=assigned_to and userid='$person' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')";
if( $FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product='$FORM{'product'}'";
}
SendSQL ($query);
my $bugcount = FetchSQLData();
$bugsperperson{$person} = $bugcount;
$bugtotal += $bugcount;
}
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
# sort people by the number of bugs they have assigned to this milestone
@people = sort bybugs @people;
my $totalpeople = @people;
if ($totalpeople > 20) {
splice @people, 0, $totalpeople-20;
}
1999-08-07 00:38:09 +00:00
2000-10-30 23:02:41 +00:00
print "<TABLE>\n";
print "<TR><TD COLSPAN=2>\n";
print "$totalpeople engineers have $bugtotal untouched new bugs.\n";
if ($totalpeople > 20) {
print "These are the 20 most doomed.";
}
print "</TD></TR>\n";
while (@people) {
$person = pop @people;
print "<TR><TD>\n";
SendSQL("select login_name from profiles where userid=$person");
my $login_name= FetchSQLData();
print("<A HREF=\"buglist.cgi?bug_status=NEW&email1=$login_name&emailtype1=substring&emailassigned_to1=1&product=Browser&product=MailNews&target_milestone=---&status_whiteboard=.&status_whiteboard_type=notregexp&bug_severity=blocker&bug_severity=critical&bug_severity=major&bug_severity=normal&bug_severity=minor&bug_severity=trivial\">\n");
print("$bugsperperson{$person} bugs");
print("</A>");
print(" for \n");
print("<A HREF=\"mailto:$login_name\">");
print("$login_name");
print("</A>\n");
print("</TD><TD>\n");
$person = pop @people;
if ($person) {
SendSQL("select login_name from profiles where userid=$person");
my $login_name= FetchSQLData();
print("<A HREF=\"buglist.cgi?bug_status=NEW&email1=$login_name&emailtype1=substring&emailassigned_to1=1&product=Browser&product=MailNews&target_milestone=---&status_whiteboard=.&status_whiteboard_type=notregexp&bug_severity=blocker&bug_severity=critical&bug_severity=major&bug_severity=normal&bug_severity=minor&bug_severity=trivial\">\n");
print("$bugsperperson{$person} bugs");
print("</A>");
print(" for \n");
print("<A HREF=\"mailto:$login_name\">");
print("$login_name");
print("</A>\n");
print("</TD></TR>\n\n");
1999-08-07 00:38:09 +00:00
}
2000-10-30 23:02:41 +00:00
}
print "</TABLE>\n";
}