fix: reduce number of database queries caused by voter

This commit is contained in:
Björn Fromme
2025-04-11 09:51:32 +02:00
parent 947b183c50
commit 24ffee7c0b
6 changed files with 38 additions and 15 deletions
+14
View File
@@ -87,6 +87,13 @@ class AssignmentRepository extends ServiceEntityRepository
->setParameter('now', new \DateTimeImmutable())
;
if (0 === $teamer->getTrainingAttendances()->count() && 0 === $teamer->getLicenses()->count()) {
$qb
->andWhere($qb->expr()->eq($qb->expr()->count('job_profile.requiredLicenses'), 0))
->andWhere($qb->expr()->eq($qb->expr()->count('job_profile.requiredTrainings'), 0))
;
}
$this->applyFilterSettings($filterDto, $qb);
return $qb->getQuery();
@@ -280,6 +287,13 @@ class AssignmentRepository extends ServiceEntityRepository
->setParameter('dateFrom', new \DateTimeImmutable())
;
if (0 === $teamer->getTrainingAttendances()->count() && 0 === $teamer->getLicenses()->count()) {
$qb
->andWhere($qb->expr()->eq($qb->expr()->count('job_profile.requiredLicenses'), 0))
->andWhere($qb->expr()->eq($qb->expr()->count('job_profile.requiredTrainings'), 0))
;
}
return $qb
->orderBy('assignment.createdAt', 'DESC')
->setMaxResults($limit)