From 6b09109e660de8fe21818d48ed9a0773441ec65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 11 Apr 2025 18:00:39 +0200 Subject: [PATCH] fix: correct database query --- src/Repository/AssignmentRepository.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Repository/AssignmentRepository.php b/src/Repository/AssignmentRepository.php index dca991d..6d3c879 100644 --- a/src/Repository/AssignmentRepository.php +++ b/src/Repository/AssignmentRepository.php @@ -67,6 +67,7 @@ class AssignmentRepository extends ServiceEntityRepository ->select('assignment', 'destination', 'job_profile', 'application', 'disposition') ->innerJoin('assignment.destination', 'destination') ->innerJoin('assignment.jobProfile', 'job_profile') + ->leftJoin('job_profile.requiredTrainings', 'required_training') ->where($qb->expr()->andX( $qb->expr()->orX( $qb->expr()->gt('destination.dateFrom', ':now'), @@ -89,8 +90,9 @@ class AssignmentRepository extends ServiceEntityRepository 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)) + ->andWhere($qb->expr()->eq('job_profile.requiredLicenses', ':requiredLicenses')) + ->setParameter('requiredLicenses', '[]') + ->andWhere($qb->expr()->isNull('required_training')) ; } @@ -267,6 +269,7 @@ class AssignmentRepository extends ServiceEntityRepository ->select('assignment', 'destination', 'job_profile') ->innerJoin('assignment.destination', 'destination') ->innerJoin('assignment.jobProfile', 'job_profile') + ->leftJoin('job_profile.requiredTrainings', 'required_training') ->leftJoin('assignment.applications', 'application', Join::WITH, $qb->expr()->eq('application.teamer', ':teamer')) ->leftJoin('assignment.dispositions', 'disposition', Join::WITH, $qb->expr()->eq('disposition.teamer', ':teamer')) ->where($qb->expr()->andX( @@ -289,8 +292,9 @@ class AssignmentRepository extends ServiceEntityRepository 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)) + ->andWhere($qb->expr()->eq('job_profile.requiredLicenses', ':requiredLicenses')) + ->setParameter('requiredLicenses', '[]') + ->andWhere($qb->expr()->isNull('required_training')) ; }