Skip to content

Commit a0b3035

Browse files
committed
Mind the filter for the timline and requie at least 10 steps.
1 parent c858e24 commit a0b3035

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

chart.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ class TimelineIterator implements Iterator {
5353
private $step;
5454
private $position;
5555

56-
public function __construct(PDO $pdo, $stepcount) {
57-
$sql = 'CREATE TEMPORARY TABLE IF NOT EXISTS report_dates (report_date int not null) SELECT UNIX_TIMESTAMP(report_date) AS report_date FROM stat';
56+
public function __construct(PDO $pdo, $filter, $stepcount) {
57+
if ($stepcount < 10) {
58+
$stepcount = 10;
59+
}
60+
$sql = 'CREATE TEMPORARY TABLE IF NOT EXISTS report_dates (report_date int not null) SELECT UNIX_TIMESTAMP(report_date) AS report_date FROM stat WHERE '.$filter.' GROUP BY report_date';
5861
$row = $pdo->query($sql);
5962
$sql = "SELECT report_date FROM report_dates ORDER BY report_date ASC LIMIT 1";
6063
$row = $pdo->query($sql)->fetch();
@@ -124,7 +127,7 @@ public function current() {
124127
$graph->xAxis = new ezcGraphChartElementDateAxis();
125128
$graph->xAxis->dateFormat = "Y/m/d";
126129

127-
$data = new TimelineIterator($pdo, $_REQUEST['timeline_steps']);
130+
$data = new TimelineIterator($pdo, $filter, $_REQUEST['timeline_steps']);
128131
$graph->data['Machine 1'] = new ezcGraphArrayDataSet($data);
129132
break;
130133

0 commit comments

Comments
 (0)