diff --git a/src/Repository/ApplicationRepository.php b/src/Repository/ApplicationRepository.php index 4d3538d..41410f5 100644 --- a/src/Repository/ApplicationRepository.php +++ b/src/Repository/ApplicationRepository.php @@ -253,12 +253,15 @@ class ApplicationRepository extends ServiceEntityRepository } /** - * The raw tally grouped by normalized hotel code, split by application status. + * The raw application tally grouped by normalized hotel code. * * Mirrors DispositionRepository::getFeedbackStatisticsByNormalizedHotelCodeQuery() - the * "Bewerbungen pro Destination" screen sits next to "Feedback pro Destination" and means the * same thing by a destination and a season, so the normalization and the date filter are the * shared ones. + * + * Status is deliberately not broken out: an application's status moves over its lifetime, so a + * snapshot of the current status is not a meaningful figure for a past period. */ public function getApplicationsByDestinationQuery( ?\DateTimeImmutable $dateFrom = null, @@ -272,16 +275,10 @@ class ApplicationRepository extends ServiceEntityRepository $qb ->select( $normalizedHotelCode.' AS hotelCode', - 'SUM(CASE WHEN application.status = :statusNew THEN 1 ELSE 0 END) AS newCount', - 'SUM(CASE WHEN application.status = :statusPending THEN 1 ELSE 0 END) AS pendingCount', - 'SUM(CASE WHEN application.status = :statusRejected THEN 1 ELSE 0 END) AS rejectedCount', 'COUNT(application.id) AS totalCount' ) ->innerJoin('application.assignment', 'assignment') ->innerJoin('assignment.destination', 'destination') - ->setParameter('statusNew', Application::STATUS_NEW) - ->setParameter('statusPending', Application::STATUS_PENDING) - ->setParameter('statusRejected', Application::STATUS_REJECTED) ->groupBy('hotelCode') ->orderBy('totalCount', 'DESC') ->addOrderBy('hotelCode', 'ASC') @@ -293,14 +290,10 @@ class ApplicationRepository extends ServiceEntityRepository } /** - * Returns application counts grouped by normalized hotel code (base 3-char code), - * split into the three application statuses plus a total. + * Returns the application count grouped by normalized hotel code (base 3-char code). * * @return array */ @@ -310,9 +303,6 @@ class ApplicationRepository extends ServiceEntityRepository ): array { return array_map(static fn (array $row): array => [ 'hotelCode' => $row['hotelCode'], - 'new' => (int) $row['newCount'], - 'pending' => (int) $row['pendingCount'], - 'rejected' => (int) $row['rejectedCount'], 'total' => (int) $row['totalCount'], ], $this->getApplicationsByDestinationQuery($dateFrom, $dateTo)->getResult()); } diff --git a/templates/administrative/statistics/applications_by_destination.html.twig b/templates/administrative/statistics/applications_by_destination.html.twig index 648e2a3..56c14c6 100644 --- a/templates/administrative/statistics/applications_by_destination.html.twig +++ b/templates/administrative/statistics/applications_by_destination.html.twig @@ -41,39 +41,24 @@ Destination - Neu - In Prüfung - Abgelehnt - Gesamt + Bewerbungen {% for stat in statistics %} {{ stat.hotelCode }} - {{ stat.new }} - {{ stat.pending }} - {{ stat.rejected }} - {{ stat.total }} + {{ stat.total }} {% endfor %} - {% set totalNew = 0 %} - {% set totalPending = 0 %} - {% set totalRejected = 0 %} {% set totalAll = 0 %} {% for stat in statistics %} - {% set totalNew = totalNew + stat.new %} - {% set totalPending = totalPending + stat.pending %} - {% set totalRejected = totalRejected + stat.rejected %} {% set totalAll = totalAll + stat.total %} {% endfor %} Gesamt - {{ totalNew }} - {{ totalPending }} - {{ totalRejected }} {{ totalAll }} diff --git a/tests/Repository/ApplicationRepositoryTest.php b/tests/Repository/ApplicationRepositoryTest.php index 43ba6a1..fa36864 100644 --- a/tests/Repository/ApplicationRepositoryTest.php +++ b/tests/Repository/ApplicationRepositoryTest.php @@ -86,13 +86,15 @@ class ApplicationRepositoryTest extends KernelTestCase $this->assertStringContainsString('INNER JOIN assignment.destination destination', $dql); } - public function testApplicationsByDestinationBindsTheStatusBuckets(): void + public function testApplicationsByDestinationCountsEveryApplicationRegardlessOfStatus(): void { $query = $this->createApplicationsByDestinationQuery(); + $dql = $query->getDQL(); - $this->assertSame(Application::STATUS_NEW, $query->getParameter('statusNew')->getValue()); - $this->assertSame(Application::STATUS_PENDING, $query->getParameter('statusPending')->getValue()); - $this->assertSame(Application::STATUS_REJECTED, $query->getParameter('statusRejected')->getValue()); + // status moves over an application's lifetime, so it is not broken out - a plain count + $this->assertStringContainsString('COUNT(application.id)', $dql); + $this->assertStringNotContainsStringIgnoringCase('application.status', $dql); + $this->assertNull($query->getParameter('statusNew')); } public function testApplicationsByDestinationAppliesTheSeasonBoundsOnlyWhenGiven(): void