summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-04-16 12:04:39 +0200
committerErich Eckner <git@eckner.net>2019-04-16 12:04:39 +0200
commit36204be4a2a198b207a4604310fba2210683a4a7 (patch)
tree6d3711d5f14d8a0650bfa924f9b24ce1ecd1e36d
parent26edecf50407357c1123dc280bcfaa568204e4a0 (diff)
downloadarchweb32-36204be4a2a198b207a4604310fba2210683a4a7.tar.xz
buildmaster/statistics.php: fix multi-selected arch
-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;