commit 138f356b3c5834cdf317a6ce348e4c153638c331
parent 6a243cba4dc6a17e49e21591d1f36c62b1397a17
Author: Daniel Gultsch <daniel@gultsch.de>
Date: Sun, 19 Jun 2016 12:24:08 +0200
add cli paramater to html rendered to turn on ranking
Diffstat:
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/reports/tohtml.php b/reports/tohtml.php
@@ -62,27 +62,32 @@ function comp_header($a, $b) {
}
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);
+ $count_a = calc_score($a);
+ $count_b = calc_score($b);
if ($count_a == $count_b) {
return 0;
}
return ($count_a > $count_b) ? -1 : 1;
}
+function calc_score($report) {
+ $headers = $GLOBALS["headers"];
+ $score = 0;
+ $i = 1;
+ foreach($headers as $key) {
+ if (array_key_exists($key,$report) && 'PASSED' === $report[$key]) {
+ $score += pow(2,$i);
+ }
+ $i++;
+ }
+ return $score;
+}
$reports = json_decode(file_get_contents('complete.json'),true);
$headers = array_keys(reset($reports));
-uasort($reports, "comp_report");
-usort($headers, "comp_header");
+if (count($argv) >= 2 && $argv[1] === 'ranked') {
+ usort($headers, "comp_header");
+ uasort($reports, "comp_report");
+}
?>
<table>
<thead>
diff --git a/reports/tojson.sh b/reports/tojson.sh
@@ -6,7 +6,7 @@ echo -n '{'
for report in "${reports[@]}"; do
server=$(echo $report | sed 's/.txt//')
echo -n "\"$server\":"
- echo -n '{' ; tail -n 16 $report | head -n 11 | sed 's/running //' | sed 's/…//' | awk -F '\t\t' '{ printf "\"" $1 "\":\"" $2 "\""; if (NR != 11) printf "," }'; echo -n '}'
+ echo -n '{' ; tail -n 17 $report | head -n 12 | sed 's/running //' | sed 's/…//' | awk -F '\t\t' '{ printf "\"" $1 "\":\"" $2 "\""; if (NR != 12) printf "," }'; echo -n '}'
if [[ $report != $last ]]; then echo -n ','; fi;
done;
echo '}'