commit 6a243cba4dc6a17e49e21591d1f36c62b1397a17
parent eb2f88b44f6fccf96cf349cd95a65ecf1f25b73a
Author: Daniel Gultsch <daniel@gultsch.de>
Date: Sat, 18 Jun 2016 21:03:48 +0200
optionally order output by frequency
Diffstat:
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/reports/tohtml.php b/reports/tohtml.php
@@ -17,12 +17,18 @@
table tbody tr td.failed {
background-color: #e53935;
}
+ table tbody tr td.missing {
+ background-color: #757575;
+ }
table tr:hover td.passed {
background-color: #2e7d32;
}
table tr:hover td.failed {
background-color: #c62828;
}
+ table tr:hover td.missing {
+ background-color: #424242;
+ }
table tr:hover td {
background-color: #e0e0e0;
}
@@ -36,8 +42,47 @@
</head>
<body>
<?php
+function count_frequency($needle, $reports) {
+ $count = 0;
+ foreach($reports as $report) {
+ foreach($report as $key => $value) {
+ if ($key === $needle && $value == "PASSED") {
+ $count++;
+ }
+ }
+ }
+ return $count;
+}
+function comp_header($a, $b) {
+ $reports = $GLOBALS["reports"];
+ $count_a = count_frequency($a, $reports);
+ $count_b = count_frequency($b, $reports);
+ if ($count_a == $count_b) {
+ return 0;
+ }
+ return ($count_a > $count_b) ? -1 : 1;
+}
+function count_passed($report) {
+ $count = 0;
+ foreach($report as $row) {
+ if ($row === 'PASSED') {
+ $count++;
+ }
+ }
+ return $count;
+}
+function comp_report($a, $b) {
+ $count_a = count_passed($a);
+ $count_b = count_passed($b);
+ if ($count_a == $count_b) {
+ return 0;
+ }
+ return ($count_a > $count_b) ? -1 : 1;
+}
$reports = json_decode(file_get_contents('complete.json'),true);
$headers = array_keys(reset($reports));
+uasort($reports, "comp_report");
+usort($headers, "comp_header");
?>
<table>
<thead>
@@ -55,11 +100,15 @@ $headers = array_keys(reset($reports));
foreach($reports as $server => $report) {
echo '<tr>';
echo '<td>'.htmlentities($server).'</td>';
- foreach($report as $data) {
- $pass = 'PASSED' === $data;
- echo '<td class="';
- echo $pass ? 'passed' : 'failed';
- echo '"></td>';
+ foreach($headers as $c) {
+ if (!array_key_exists($c, $report)) {
+ $class = 'missing';
+ } else if ('PASSED' === $report[$c]) {
+ $class = 'passed';
+ } else {
+ $class = 'failed';
+ }
+ echo '<td class="'.$class.'"></td>';
}
echo '</tr>';
}