diff options
Diffstat (limited to 'buildmaster')
-rw-r--r-- | buildmaster/statistics.php | 49 |
1 files changed, 38 insertions, 11 deletions
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`" ); |