Added test result averages
This commit is contained in:
parent
0510c80c34
commit
af9d788fe0
@ -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)),
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user