WIP: Implement teamer dashboard
This commit is contained in:
@@ -202,4 +202,36 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function getNewMatchingTeamerProfile(Teamer $teamer, array $availabilities, int $limit = 5): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('assignment');
|
||||
|
||||
$qb
|
||||
->select('assignment', 'destination', 'job_profile')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->innerJoin('assignment.jobProfile', 'job_profile')
|
||||
->leftJoin('assignment.applications', 'application', Join::WITH, $qb->expr()->neq('application.teamer', ':teamer'))
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->in('assignment.jobProfile', ':jobProfiles'),
|
||||
$qb->expr()->isNull('application')
|
||||
))
|
||||
->setParameter('jobProfiles', $teamer->getJobProfiles())
|
||||
->setParameter('teamer', $teamer)
|
||||
;
|
||||
|
||||
foreach ($availabilities as $availability) {
|
||||
$qb->orWhere($qb->expr()->andX(
|
||||
$qb->expr()->eq('assignment.dateFrom', ':dateFrom'),
|
||||
$qb->expr()->eq('assignment.dateTo', ':dateTo')
|
||||
));
|
||||
}
|
||||
|
||||
return $qb
|
||||
->orderBy('assignment.createdAt', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user