Added test result averages
This commit is contained in:
parent
0510c80c34
commit
af9d788fe0
@ -27,15 +27,25 @@ class Test extends Model {
|
|||||||
public function benchmarkResults() {
|
public function benchmarkResults() {
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach ($this->benchmarks as $i, $b) {
|
foreach ($this->benchmarks as $i => $b) {
|
||||||
$benchmarkResults = $this->results()->where('benchmark_id', $b->id)->get();
|
$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] = [
|
$data[$i] = [
|
||||||
'name' => $b->name,
|
'name' => $b->name,
|
||||||
'scoring' => $b->scoring,
|
'scoring' => $b->scoring,
|
||||||
'count' => count($benchmarkResults),
|
'count' => count($benchmarkResults),
|
||||||
'average' => 0,
|
'average' => (array_sum($averageResults) / count($averageResults)),
|
||||||
'minimum' => 0,
|
'minimum' => (array_sum($minimumResults) / count($minimumResults)),
|
||||||
'maximum' => 0,
|
'maximum' => (array_sum($maximumResults) / count($maximumResults)),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user