From 0510c80c344e404459a175f188016bc7399f5388 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Mon, 3 Jun 2024 11:28:24 -0400 Subject: [PATCH] Reworked test view page --- src/Models/Test.php | 18 +++++++++++++++ views/test/view.twig | 55 ++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/Models/Test.php b/src/Models/Test.php index 493db8d..68acd3d 100644 --- a/src/Models/Test.php +++ b/src/Models/Test.php @@ -24,4 +24,22 @@ class Test extends Model { return $this->belongsTo(Component::class); } + public function benchmarkResults() { + $data = []; + + foreach ($this->benchmarks as $i, $b) { + $benchmarkResults = $this->results()->where('benchmark_id', $b->id)->get(); + $data[$i] = [ + 'name' => $b->name, + 'scoring' => $b->scoring, + 'count' => count($benchmarkResults), + 'average' => 0, + 'minimum' => 0, + 'maximum' => 0, + ] + } + + return $data; + } + } diff --git a/views/test/view.twig b/views/test/view.twig index 3ef914d..fa2a831 100644 --- a/views/test/view.twig +++ b/views/test/view.twig @@ -7,11 +7,6 @@

{{ test.title }}

{{ test.description }}

-
@@ -54,36 +49,32 @@
-

Test results:

+

Benchmark results:

- {% if test.results | length > 0 %} - - +
+ + + + + + + + + + + + {% for r in test.benchmarkResults() %} - - - - - - + + + + + + - - - {% for r in test.results %} - - - - - - - - - {% endfor %} - -
BenchmarkScoring# ResultsAvg.Min.Max.
ComponentBenchmarkScoringAvg.Min.Max.{{ r.name }}{{ r.scoring | capitalize }}{{ r.count }}{{ r.average }}{{ r.minimum ? r.minimum : 'N/a' }}{{ r.maximum ? r.maximum : 'N/a' }}
{{ test.component.name }}{{ r.benchmark.name }}{{ r.benchmark.scoring | capitalize }}{{ r.average }}{{ r.minimum ? r.minimum : 'N/a' }}{{ r.maximum ? r.maximum : 'N/a' }}
- {% else %} -

There are no results associated with this test.

- {% endif %} + {% endfor %} + +
{% endblock %}