feat: expose winter placements to n8n over an api endpoint
This commit is contained in:
1 parent
4ff963d1e2
commit
0bc77b7463
17 files changed
+977
-18
No files matched your search
@@ -431,4 +431,53 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
->getSingleColumnResult()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The assignments the n8n placements feed reports: published, in one of the houses, for one of
|
||||
* the job profiles, and overlapping the range. Placements, their teamers and documents come
|
||||
* fetch-joined - every place row needs them. All placements are loaded, called-off ones included:
|
||||
* a fetch join on a filtered collection would leave the assignment with a partial one, and
|
||||
* Assignment::getPlaces() leaves them out anyway.
|
||||
*
|
||||
* @param list<string> $houseCodes matched against the first three characters of the hotel code
|
||||
* @param list<int> $jobProfileIds
|
||||
*
|
||||
* @return list<Assignment>
|
||||
*/
|
||||
public function findForPlacementExport(\DateTimeImmutable $from, \DateTimeImmutable $to, array $houseCodes, array $jobProfileIds): array
|
||||
{
|
||||
if ([] === $houseCodes || [] === $jobProfileIds) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$qb = $this->createQueryBuilder('assignment');
|
||||
|
||||
return $qb
|
||||
->addSelect('destination', 'jobProfile', 'disposition', 'teamer', 'document')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->innerJoin('assignment.jobProfile', 'jobProfile')
|
||||
->leftJoin('assignment.dispositions', 'disposition')
|
||||
->leftJoin('disposition.teamer', 'teamer')
|
||||
->leftJoin('disposition.documents', 'document')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->lte('destination.dateFrom', ':to'),
|
||||
$qb->expr()->gte('destination.dateTo', ':from'),
|
||||
$qb->expr()->in('SUBSTRING(destination.hotelCode, 1, 3)', ':houseCodes'),
|
||||
$qb->expr()->in('jobProfile.id', ':jobProfileIds'),
|
||||
$qb->expr()->notIn('assignment.status', ':excludedStatuses'),
|
||||
$qb->expr()->isNull('assignment.deletedAt'),
|
||||
$qb->expr()->isNull('destination.deletedAt'),
|
||||
))
|
||||
->orderBy('destination.dateFrom')
|
||||
->addOrderBy('destination.hotelCode')
|
||||
->addOrderBy('assignment.id')
|
||||
->setParameter('from', $from->format('Y-m-d'))
|
||||
->setParameter('to', $to->format('Y-m-d'))
|
||||
->setParameter('houseCodes', $houseCodes)
|
||||
->setParameter('jobProfileIds', $jobProfileIds)
|
||||
->setParameter('excludedStatuses', [Assignment::STATUS_DRAFT, Assignment::STATUS_CALLED_OFF, Assignment::STATUS_DELETED])
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user