cvs: php-bugs-web / bugstats.php
| From: | jim winstead | Date: | Sat, 20 Oct 2001 06:08:15 +0000 |
| Subject: | cvs: php-bugs-web / bugstats.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-7114@lists.php.net to get a copy of this message | ||
jimw Sat Oct 20 02:08:15 2001 EDT
Modified files:
/php-bugs-web bugstats.php
Log:
let mysql do the heavy lifting on figuring out the average, quickest, slowest, and median time to
close. something is screwy when we do it in the php code.
Index: php-bugs-web/bugstats.php
diff -u php-bugs-web/bugstats.php:1.3 php-bugs-web/bugstats.php:1.4
--- php-bugs-web/bugstats.php:1.3 Sun Sep 23 19:27:04 2001
+++ php-bugs-web/bugstats.php Sat Oct 20 02:08:15 2001
@@ -17,7 +17,7 @@
@mysql_select_db("php3")
or die("unable to select database");
-$query = "SELECT *,UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1) AS timetoclose FROM bugdb";
+$query = "SELECT status,dev_id,bug_type,email,php_version,php_os FROM bugdb";
if ($phpver > 0) {
$query .= " WHERE SUBSTRING(php_version,1,1) = '$phpver'";
@@ -31,9 +31,6 @@
$bug_type['all'][$row[bug_type]]++;
switch (strtolower($row[status])) {
case "closed":
- if ($row[timetoclose] > 0) {
- $time_to_close[] = $row[timetoclose];
- }
/* falls through */
case "bogus":
$closed_by[$row[dev_id]]++;
@@ -143,20 +140,20 @@
echo "</table>\n";
-sort($time_to_close);
-$c=count($time_to_close);
-$sum=0;
-for($i=0;$i<$c;$i++) {
- $sum+=$time_to_close[$i];
-}
-$median = $time_to_close[(int)($c/2)];
+$query = "SELECT COUNT(*) AS count,MAX(UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1)) AS
slowest,MIN(UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1)) AS
quickest,AVG(UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1)) AS average FROM bugdb WHERE ts2 >
ts1";
+$res = mysql_query($query);
+$row = mysql_fetch_array($res);
+$half = $row['count']/2;
+$query = "SELECT UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1) AS half FROM bugdb WHERE ts2 > ts1
ORDER BY UNIX_TIMESTAMP(ts2)-UNIX_TIMESTAMP(ts1) LIMIT $half,1";
+$res = mysql_query($query);
+$median = mysql_result($res,0);
echo "<p><b>Bug Report Time to Close Stats</b>\n";
echo "<table>\n";
-echo "<tr bgcolor=#aabbcc><th align=right>Average life of a
report:</th><td
bgcolor=#ccddee>".ShowTime((int)($sum/$c))."</td></tr>\n";
+echo "<tr bgcolor=#aabbcc><th align=right>Average life of a
report:</th><td
bgcolor=#ccddee>".ShowTime((int)$row[average])."</td></tr>\n";
echo "<tr bgcolor=#aabbcc><th align=right>Median life of a
report:</th><td
bgcolor=#ccddee>".ShowTime($median)."</td></tr>\n";
-echo "<tr bgcolor=#aabbcc><th align=right>Slowest report closure:</th><td
bgcolor=#ccddee>".ShowTime($time_to_close[$c-1])."</td></tr>\n";
-echo "<tr bgcolor=#aabbcc><th align=right>Quickest report
closure:</th><td
bgcolor=#ccddee>".ShowTime($time_to_close[0])."</td></tr>\n";
+echo "<tr bgcolor=#aabbcc><th align=right>Slowest report closure:</th><td
bgcolor=#ccddee>".ShowTime($row[slowest])."</td></tr>\n";
+echo "<tr bgcolor=#aabbcc><th align=right>Quickest report
closure:</th><td
bgcolor=#ccddee>".ShowTime($row[quickest])."</td></tr>\n";
echo "</table>\n";
echo "<p><b>Who is closing the bug reports?</b>\n";