summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildmaster/statistics.php35
1 files changed, 12 insertions, 23 deletions
diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php
index 7d706c6..097be80 100644
--- a/buildmaster/statistics.php
+++ b/buildmaster/statistics.php
@@ -7,19 +7,10 @@ if (array_key_exists("from", $_GET))
else
$min_time="\"-7 00:00:00\"";
-if (array_key_exists("arch", $_GET)) {
+if (array_key_exists("arch", $_GET))
$arch_filter = arch_filter_query("architectures");
- $combiner_left = "";
- $combiner_right = "";
- $grouper = "";
- $joiner = " JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`";
-} else {
+else
$arch_filter = "1";
- $combiner_left = "SUM(";
- $combiner_right = ")";
- $grouper = " GROUP BY `statistics`.`date`";
- $joiner = "";
-};
$column_list = array(
"pending_tasks_count",
@@ -36,21 +27,19 @@ $column_list = array(
);
function combine_column($name) {
- global $combiner_left;
- global $combiner_right;
- return $combiner_left . "`statistics`.`" . $name . "`" . $combiner_right . " AS `" . $name . "`";
+ return "SUM(`statistics`.`" . $name . "`) AS `" . $name . "`";
}
$result = mysql_run_query(
- "SELECT DISTINCT ".
- "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," .
- implode(",",array_map("combine_column",$column_list)) .
- "FROM `statistics` " .
- $joiner .
- "WHERE `statistics`.`date`>=ADDDATE(NOW()," . $min_time . ") " .
- "AND " . $arch_filter .
- $grouper .
- "ORDER BY `statistics`.`date`"
+ "SELECT DISTINCT".
+ " UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," .
+ implode(",", array_map("combine_column", $column_list)) .
+ " FROM `statistics`" .
+ " JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`" .
+ " WHERE `statistics`.`date`>=ADDDATE(NOW()," . $min_time . ")" .
+ " AND " . $arch_filter .
+ " GROUP BY `statistics`.`date`" .
+ " ORDER BY `statistics`.`date`"
);
$t_min = -1;