From cf9b879f29f0d01c93882cc40f6c1ce63d870efc Mon Sep 17 00:00:00 2001 From: "tara%tequilarista.org" <> Date: Tue, 24 Oct 2000 04:44:30 +0000 Subject: part of gervase markham's duplicates tracking functionality --- duplicates.cgi | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100755 duplicates.cgi (limited to 'duplicates.cgi') diff --git a/duplicates.cgi b/duplicates.cgi new file mode 100755 index 000000000..a45da6bb2 --- /dev/null +++ b/duplicates.cgi @@ -0,0 +1,186 @@ +#!/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 +# +# Generates mostfreq list from data collected by collectstats.pl. + +use diagnostics; +use strict; +use CGI "param"; +use DB_File; +require "globals.pl"; +require "CGI.pl"; + +ConnectToDatabase(); +GetVersionTable(); + +my %count; +my $dobefore = 0; +my $before = ""; +my %before; + +my $changedsince; +my $maxrows = 500; # arbitrary limit on max number of rows + +my $today = &days_ago(0); + +# Open today's record of dupes +if (-e "data/mining/dupes$today.db") +{ + dbmopen(%count, "data/mining/dupes${today}.db", 0644) || die "Can't open today's dupes file: $!"; +} +else +{ + # Try yesterday's, then (in case today's hasn't been created yet) :-) + $today = &days_ago(1); + if (-e "data/mining/dupes$today.db") + { + dbmopen(%count, "data/mining/dupes${today}.db", 0644) || die "Can't open yesterday's dupes file: $!"; + } + else + { + die "There are no duplicate statistics for today or yesterday."; + } +} + +# Check for changedsince param, and see if it's a positive integer +if (defined(param("changedsince")) && param("changedsince") =~ /^\d{1,4}$/) +{ + $changedsince = param("changedsince"); +} +else +{ + # Otherwise, default to one week + $changedsince = "7"; +} + +$before = &days_ago($changedsince); + +# check for max rows parameter +if (defined(param("maxrows")) && param("maxrows") =~ /^\d{1,4}$/) +{ + $maxrows = param("maxrows"); +} + +if (-e "data/mining/dupes${before}.db") +{ + dbmopen(%before, "data/mining/dupes${before}.db", 0644) && ($dobefore = 1); +} + +print "Content-type: text/html\n"; +print "\n"; +PutHeader("Most Frequently Reported Bugs"); + +print Param("mostfreqhtml"); + +print " + + + + +\n"; + +if ($dobefore) +{ + print " "; +} + +print " + + + + + +\n\n"; + +my %delta; + +# Calculate the deltas if we are doing a "before" +if ($dobefore) +{ + foreach (keys(%count)) + { + $delta{$_} = $count{$_} - $before{$_}; + } +} + +# Offer the option of sorting on total count, or on the delta +my @sortedcount; + +if (defined(param("sortby")) && param("sortby") == "delta") +{ + @sortedcount = sort by_delta keys(%count); +} +else +{ + @sortedcount = sort by_dup_count keys(%count); +} + +my $i = 0; + +foreach (@sortedcount) +{ + my $id = $_; + SendSQL("SELECT component, bug_severity, op_sys, target_milestone, short_desc FROM " . + "bugs WHERE bug_id = $id"); + my ($component, $severity, $op_sys, $milestone, $summary) = FetchSQLData(); + print ""; + print '"; + print ""; + if ($dobefore) + { + print ""; + } + print "\n "; + print ""; + print ""; + print ""; + print ""; + print "\n"; + + $i++; + if ($i == $maxrows) + { + last; + } +} + +print "
Bug #
Dupe
Count
Change in last
$changedsince day(s)
Component
Severity
Op Sys
Target
Milestone
Summary
'; + print $id . "
$count{$id}
$delta{$id}
$component
$severity
$op_sys
$milestone
$summary


"; +PutFooter(); + + +sub by_dup_count +{ + return -($count{$a} <=> $count{$b}); +} + +sub by_delta +{ + return -($delta{$a} <=> $delta{$b}); +} + +sub days_ago +{ + my ($dom, $mon, $year) = (localtime(time - ($_[0]*24*60*60)))[3, 4, 5]; + return sprintf "%04d%02d%02d", 1900 + $year, ++$mon, $dom; +} + -- cgit v1.2.3-24-g4f1b