Added test result averages

This commit is contained in:
Gregory Ballantine 2024-06-03 11:36:47 -04:00
parent 0510c80c34
commit af9d788fe0

View File

@ -27,15 +27,25 @@ class Test extends Model {
public function benchmarkResults() {
$data = [];
foreach ($this->benchmarks as $i, $b) {
foreach ($this->benchmarks as $i => $b) {
$benchmarkResults = $this->results()->where('benchmark_id', $b->id)->get();
$averageResults = [];
$minimumResults = [];
$maximumResults = [];
foreach ($benchmarkResults as $r) {
array_push($averageResults, $r->average);
array_push($minimumResults, $r->minimum);
array_push($maximumResults, $r->maximum);
}
$data[$i] = [
'name' => $b->name,
'scoring' => $b->scoring,
'count' => count($benchmarkResults),
'average' => 0,
'minimum' => 0,
'maximum' => 0,
'average' => (array_sum($averageResults) / count($averageResults)),
'minimum' => (array_sum($minimumResults) / count($minimumResults)),
'maximum' => (array_sum($maximumResults) / count($maximumResults)),
]
}