From 36204be4a2a198b207a4604310fba2210683a4a7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 16 Apr 2019 12:04:39 +0200 Subject: buildmaster/statistics.php: fix multi-selected arch --- buildmaster/statistics.php | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'buildmaster/statistics.php') 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; -- cgit v1.2.3