feat: display teamers' average ratings in several locations
This commit is contained in:
@@ -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>
|
||||
*/
|
||||
|
||||
@@ -69,8 +69,9 @@ class ApplicationRepository extends ServiceEntityRepository
|
||||
$qb = $this->createQueryBuilder('application');
|
||||
|
||||
return $qb
|
||||
->select('application', 'teamer')
|
||||
->select('application', 'teamer', 'feedback')
|
||||
->innerJoin('application.teamer', 'teamer')
|
||||
->leftJoin('teamer.feedback', 'feedback')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->eq('application.assignment', ':assignment'),
|
||||
$qb->expr()->neq('application.status', ':status')
|
||||
|
||||
@@ -96,8 +96,9 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
$qb = $this->createQueryBuilder('disposition');
|
||||
|
||||
return $qb
|
||||
->select('disposition', 'teamer')
|
||||
->select('disposition', 'teamer', 'feedback')
|
||||
->innerJoin('disposition.teamer', 'teamer')
|
||||
->leftJoin('teamer.feedback', 'feedback')
|
||||
->where($qb->expr()->eq('disposition.assignment', ':assignment'))
|
||||
->setParameter('assignment', $assignment)
|
||||
->getQuery()
|
||||
|
||||
@@ -32,10 +32,11 @@ class TeamerRepository extends ServiceEntityRepository
|
||||
$qb = $this->createQueryBuilder('teamer');
|
||||
|
||||
$qb
|
||||
->select('teamer', 'user')
|
||||
->select('teamer', 'user', 'feedback')
|
||||
->leftJoin('teamer.availabilities', 'availability')
|
||||
->leftJoin('teamer.jobProfiles', 'job_profile')
|
||||
->leftJoin('teamer.licenses', 'license')
|
||||
->leftJoin('teamer.feedback', 'feedback')
|
||||
->leftJoin('teamer.user', 'user')
|
||||
;
|
||||
|
||||
|
||||
@@ -89,8 +89,12 @@ class AppRuntime implements RuntimeExtensionInterface
|
||||
return $this->intlExtension->formatCurrency($amount, 'EUR');
|
||||
}
|
||||
|
||||
public function formatRating(int $rating): string
|
||||
public function formatRating(?int $rating): string
|
||||
{
|
||||
if (null === $rating) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
// Ratings are stored as integers so divide by 100 first
|
||||
$rating = $rating / 100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user