From ea6b55847dd628792f1e92f9dbc75a872b0b76a8 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 17 Oct 2018 14:22:21 +0200 Subject: buildmaster/statistics.php: now knows about `statistics`.`architecture` --- buildmaster/statistics.php | 49 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'buildmaster') diff --git a/buildmaster/statistics.php b/buildmaster/statistics.php index cf3b0d0..5378616 100644 --- a/buildmaster/statistics.php +++ b/buildmaster/statistics.php @@ -7,22 +7,49 @@ if (isset($_GET["from"])) else $min_time="\"-7 00:00:00\""; +if (isset($_GET["arch"])) { + $arch_filter="`architectures`.`name`=from_base64(\"" . base64_encode($_GET["arch"]) . "\")"; + $combiner_left=""; + $combiner_right=""; + $grouper=""; + $joiner=" JOIN `architectures` ON `statistics`.`architecture`=`architectures`.`id`"; +} else { + $arch_filter="1"; + $combiner_left="SUM("; + $combiner_right=")"; + $grouper=" GROUP BY `statistics`.`date`"; + $joiner=""; +}; + +$column_list = array( + "pending_tasks_count", + "pending_packages_count", + "staging_packages_count", + "testing_packages_count", + "tested_packages_count", + "broken_tasks_count", + "dependency_loops_count", + "dependency_looped_tasks_count", + "locked_tasks_count", + "blocked_tasks_count", + "next_tasks_count" +); + +function combine_column($name) { + global $combiner_left; + global $combiner_right; + return $combiner_left . "`statistics`.`" . $name . "`" . $combiner_right . " AS `" . $name . "`"; +} + $result = mysql_run_query( "SELECT DISTINCT ". "UNIX_TIMESTAMP(`statistics`.`date`) AS `date`," . - "`statistics`.`pending_tasks_count`," . - "`statistics`.`pending_packages_count`," . - "`statistics`.`staging_packages_count`," . - "`statistics`.`testing_packages_count`," . - "`statistics`.`tested_packages_count`," . - "`statistics`.`broken_tasks_count`," . - "`statistics`.`dependency_loops_count`," . - "`statistics`.`dependency_looped_tasks_count`," . - "`statistics`.`locked_tasks_count`," . - "`statistics`.`blocked_tasks_count`," . - "`statistics`.`next_tasks_count`" . + 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`" ); -- cgit v1.2.3