feat: refactor staffing status assignment and filtering

This commit is contained in:
Björn Fromme
2024-07-16 17:34:50 +02:00
parent fa9c68c463
commit 5dd2f79c2d
14 changed files with 128 additions and 52 deletions
+5 -22
View File
@@ -40,7 +40,6 @@ class AssignmentRepository extends ServiceEntityRepository
->leftJoin('assignment.applications', 'application')
->leftJoin('assignment.dispositions', 'disposition')
->leftJoin('disposition.teamer', 'teamer')
->groupBy('assignment')
;
$this->applyFilterSettings($filterDto, $qb);
@@ -117,27 +116,11 @@ class AssignmentRepository extends ServiceEntityRepository
;
}
if (null !== $status = $filterDto->getStatus()) {
switch ($status) {
case Assignment::STATUS_STAFFED:
$qb->having('assignment.availableDispositions = COUNT(disposition.id)');
break;
case Assignment::STATUS_PARTLY_STAFFED:
$qb
->having('COUNT(disposition.id) > 0')
->andHaving('assignment.availableDispositions > COUNT(disposition.id)')
;
break;
case Assignment::STATUS_STAFFING:
$qb
->having('COUNT(disposition.id) = 0')
->andHaving('COUNT(application.id) > 0')
;
break;
case Assignment::STATUS_UNSTAFFED:
$qb->having('COUNT(disposition.id) = 0');
break;
}
if (0 < count($filterDto->getStatus())) {
$qb
->andWhere($qb->expr()->in('assignment.staffingStatus', ':status'))
->setParameter('status', $filterDto->getStatus())
;
}
if (null !== $dateFrom = $filterDto->getDateFrom()) {