Re: bug in pearweb/public_html/package-stats-graph.php
| From: | Alexey Borzov | Date: | Sun, 15 Jun 2003 19:53:03 +0000 |
| Subject: | Re: bug in pearweb/public_html/package-stats-graph.php | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17492@lists.php.net to get a copy of this message | ||
Hi!
Martin Jansen wrote:
Looks like the patch was insufficient... :[ The keys to arrays contained only the month info and thus data gets overwritten now. Here is another attempt at fixing this, please test the query before applying as I don't have MySQL installed. Index: package-stats-graph.php =================================================================== RCS file: /repository/pearweb/public_html/package-stats-graph.php,v retrieving revision 1.15 diff -r1.15 package-stats-graph.php 44,49c44,49 < for ($i=date('n'), $year=date('Y'); count(@$x_axis) < 12; $i--) {Thus months of different years are grouped together. The marked line should be GROUP BY YEAR(d.dl_when), MONTH(d.dl_when)Patch applied.
< if ($i == 0) {
< $i = 12;
< $year--;
< }
< $x_axis[$i] = date("M", mktime(0,0,0,$i,1,$year));
---
$year = date('Y') - 1;
$month = date('n') + 1;
$x_axis = array();
for ($i = 0; $i < 12; $i++) {
$time = mktime(0, 0, 0, $month + $i, 1, $year);
$x_axis[date('Ym', $time)] = date('M', $time);
71c71
< $sql = sprintf("SELECT UNIX_TIMESTAMP(d.dl_when) AS date, COUNT(*) AS downloads
---
$sql = sprintf("SELECT YEAR(d.dl_when) AS dyear, MONTH(d.dl_when) AS dmonth, COUNT(*) AS downloads
73a74
AND d.dl_when > (now() - INTERVAL 1 YEAR)83c84,87
< $y_axis[date('n', $row['date'])] = $row['downloads'];
---
$key = sprintf('%04d%02d', $row['dyear'], $row['dmonth']);
if (isset($y_axis[$key])) {
$y_axis[$key] = $row['downloads'];
}
88c92
< $bplots[$rid] = new BarPlot(array_reverse(array_values($y_axis)));---
< $x_axis = array_reverse(array_values($x_axis)); ---$bplots[$rid] = new BarPlot(array_values($y_axis));97c101
$x_axis = array_values($x_axis);