From e87985550884a1f7f46c92ba31d95217ca68a726 Mon Sep 17 00:00:00 2001 From: "harrison%netscape.com" <> Date: Tue, 27 Oct 1998 04:15:13 +0000 Subject: patch from Sam Ziegler , bug graphs available, minor hacks. --- reports.cgi | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 161 insertions(+), 12 deletions(-) (limited to 'reports.cgi') diff --git a/reports.cgi b/reports.cgi index e1972bd2e..707de6ac0 100755 --- a/reports.cgi +++ b/reports.cgi @@ -22,28 +22,52 @@ use diagnostics; use strict; +use Chart::Lines; require "CGI.pl"; require "globals.pl"; use vars @::legal_product; +my $dir = "data/mining"; my $week = 60 * 60 * 24 * 7; my @status = qw (NEW ASSIGNED REOPENED); -ConnectToDatabase(); +# while this looks odd/redundant, it allows us to name +# functions differently than the value passed in -print < \&most_doomed, + "show_chart" => \&show_chart, + ); + +# patch from Sam Ziegler : +# +# "reports.cgi currently has it's own idea of what +# the header should be. This patch sets it to the +# system wide header." +print "Content-type: text/html\n\n"; + +if (defined $::FORM{'nobanner'}) + { +print < - -Bugzilla Reports - +Bug Reports FIN + } +else + { + PutHeader ("Bug Reports") unless (defined $::FORM{'nobanner'}); + } + +ConnectToDatabase(); -&header unless (defined $::FORM{'nobanner'}); +# $::FORM{'product'} = "Mozilla"; +# &show_chart(); +# exit; if (! defined $::FORM{'product'}) { @@ -51,7 +75,29 @@ if (! defined $::FORM{'product'}) } else { - &most_doomed; + # we want to be careful about what subroutines + # can be called from outside. modify %reports + # accordingly when a new report type is added + + if (! defined $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.

\n"; + foreach (keys %::FORM) + { + print "$_ : " . + ($::FORM{$_} ? $::FORM{$_} : "undef") . "
\n"; + } + exit; + } + + &{$f}; } print < +Output: + + + Switches:  Links to Bugs
@@ -101,10 +154,6 @@ $product_popup FIN } -########################## -# they sent us a project # -########################## - sub most_doomed { my $when = localtime (time); @@ -323,3 +372,103 @@ sub header BORDER=0 WIDTH=600 HEIGHT=58> FIN } + +sub show_chart + { + my $when = localtime (time); + + print < +FIN + + my @dates; + my @open; my @assigned; my @reopened; + + my $file = join '/', $dir, $::FORM{'product'}; + my $image = "$file.gif"; + + if (! open FILE, $file) + { + &die_politely ("The tool which gathers bug counts has not been run yet."); + } + + while () + { + chomp; + next if ($_ =~ /^#/ or ! $_); + my ($date, $open, $assigned, $reopened) = split /\|/, $_; + my ($yy, $mm, $dd) = $date =~ /^\d{2}(\d{2})(\d{2})(\d{2})$/; + + push @dates, "$mm/$dd/$yy"; + push @open, $open; + push @assigned, $assigned; + push @reopened, $reopened; + } + + close FILE; + + if ($#dates < 1) + { + &die_politely ("We don't have enough data points to make a graph (yet)"); + } + + my $img = Chart::Lines->new (800, 600); + my @labels = qw (New Assigned Reopened); + my @when; + my $i = 0; + my @data; + + push @data, \@dates; + push @data, \@open; + push @data, \@assigned; + push @data, \@reopened; + + my %settings = + ( + "title" => "Bug Charts for $::FORM{'product'}", + "x_label" => "Dates", + "y_label" => "Bug Count", + "grey_background" => 1, + "legend_labels" => \@labels, + ); + + $img->set (%settings); + + open IMAGE, ">$image" or die "$image: $!"; + $img->gif (*IMAGE, \@data); + close IMAGE; + + print < +
+
+FIN + } + +sub die_politely + { + my $msg = shift; + + print < + + + + +
+Sorry, but ... +

+There is no graph available for $::FORM{'product'}

+ + +$msg +

+ +

+

+FIN + + exit; + } + + -- cgit v1.2.3-24-g4f1b