diff --git a/src/Repository/AssignmentRepository.php b/src/Repository/AssignmentRepository.php index 3047866..339a4b1 100644 --- a/src/Repository/AssignmentRepository.php +++ b/src/Repository/AssignmentRepository.php @@ -270,6 +270,8 @@ class AssignmentRepository extends ServiceEntityRepository public function getNewMatchingTeamerProfile(Teamer $teamer, int $limit = 5): array { + $availableAssignmentsIds = $this->getAvailableAssignmentsIds(); + $qb = $this->createQueryBuilder('assignment'); $qb @@ -280,21 +282,15 @@ class AssignmentRepository extends ServiceEntityRepository ->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( - $qb->expr()->eq('assignment.status', ':status'), $qb->expr()->neq('assignment.staffingStatus', ':staffingStatus'), $qb->expr()->in('assignment.jobProfile', ':jobProfiles'), $qb->expr()->isNull('application'), $qb->expr()->isNull('disposition'), - $qb->expr()->orX( - $qb->expr()->gt('assignment.dateFrom', ':dateFrom'), - $qb->expr()->gt('destination.dateFrom', ':dateFrom') - ) + $qb->expr()->in('assignment.id', $availableAssignmentsIds) )) - ->setParameter('status', Assignment::STATUS_PUBLISHED) ->setParameter('staffingStatus', Assignment::STATUS_STAFFED) ->setParameter('jobProfiles', $teamer->getJobProfiles()) ->setParameter('teamer', $teamer) - ->setParameter('dateFrom', new \DateTimeImmutable()) ; if (0 === $teamer->getTrainingAttendances()->count() && 0 === $teamer->getLicenses()->count()) {