feat: filter assignments by assignment status
This commit is contained in:
@@ -40,6 +40,7 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
->leftJoin('assignment.applications', 'application')
|
||||
->leftJoin('assignment.dispositions', 'disposition')
|
||||
->leftJoin('disposition.teamer', 'teamer')
|
||||
->groupBy('assignment')
|
||||
;
|
||||
|
||||
$this->applyFilterSettings($filterDto, $qb);
|
||||
@@ -67,6 +68,7 @@ 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'))
|
||||
->groupBy('assignment')
|
||||
->setParameter('teamer', $teamer)
|
||||
->setParameter('now', new \DateTimeImmutable())
|
||||
;
|
||||
@@ -79,10 +81,23 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
private function applyFilterSettings(AssignmentFilterDto $filterDto, QueryBuilder $qb): void
|
||||
{
|
||||
if (null !== $status = $filterDto->getStatus()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->eq('assignment.status', ':status'))
|
||||
->setParameter('status', $status)
|
||||
;
|
||||
switch ($status) {
|
||||
case Assignment::STATUS_STAFFED:
|
||||
$qb->having('assignment.availableDispositions = COUNT(disposition.id)');
|
||||
break;
|
||||
case Assignment::STATUS_PARTLY_STAFFED:
|
||||
$qb
|
||||
->having('assignment.availableDispositions > COUNT(disposition.id)')
|
||||
->andHaving('COUNT(application.id) = 0')
|
||||
;
|
||||
break;
|
||||
case Assignment::STATUS_STAFFING:
|
||||
$qb
|
||||
->having('COUNT(disposition.id) = 0')
|
||||
->andHaving('COUNT(application.id) > 0')
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $dateFrom = $filterDto->getDateFrom()) {
|
||||
|
||||
Reference in New Issue
Block a user