feat: display teamers' average ratings in several locations

This commit is contained in:
Björn Fromme
2024-01-10 13:05:47 +01:00
parent 7215b3077b
commit 159ea37a42
9 changed files with 49 additions and 14 deletions
+17
View File
@@ -496,6 +496,23 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
public function getAverageRating(): ?int
{
$feedbackCount = $this->getFeedback()->count();
if (0 === $feedbackCount) {
return null;
}
$sum = 0;
foreach ($this->getFeedback() as $feedback) {
$sum += $feedback->getAverageRating();
}
return $sum / $feedbackCount;
}
/**
* @return Collection<int, TrainingAttendance>
*/