From 10535744b7d6279a0004ad8a51ec68d8dd3c752f Mon Sep 17 00:00:00 2001 From: Tom Udding Date: Sun, 20 Oct 2024 22:21:54 +0200 Subject: [PATCH] fix: unnecessary decision counting while retrieving past meetings --- .../src/Controller/MemberController.php | 18 +++++++++--------- module/Decision/src/Mapper/Meeting.php | 7 +------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/module/Decision/src/Controller/MemberController.php b/module/Decision/src/Controller/MemberController.php index 747cf06730..f25540c924 100644 --- a/module/Decision/src/Controller/MemberController.php +++ b/module/Decision/src/Controller/MemberController.php @@ -43,17 +43,17 @@ public function indexAction(): ViewModel // Get the latest 3 meetings of each type and flatten result $meetingsCollection = [ - MeetingTypes::ALV->getAbbreviation($this->translator) => array_column( - $this->decisionService->getPastMeetings(3, MeetingTypes::ALV), - 0, + MeetingTypes::ALV->getAbbreviation($this->translator) => $this->decisionService->getPastMeetings( + 3, + MeetingTypes::ALV, ), - MeetingTypes::BV->getAbbreviation($this->translator) => array_column( - $this->decisionService->getPastMeetings(3, MeetingTypes::BV), - 0, + MeetingTypes::BV->getAbbreviation($this->translator) => $this->decisionService->getPastMeetings( + 3, + MeetingTypes::BV, ), - MeetingTypes::VV->getAbbreviation($this->translator) => array_column( - $this->decisionService->getPastMeetings(3, MeetingTypes::VV), - 0, + MeetingTypes::VV->getAbbreviation($this->translator) => $this->decisionService->getPastMeetings( + 3, + MeetingTypes::VV, ), ]; diff --git a/module/Decision/src/Mapper/Meeting.php b/module/Decision/src/Mapper/Meeting.php index a10344a8d2..81c3cef3c3 100644 --- a/module/Decision/src/Mapper/Meeting.php +++ b/module/Decision/src/Mapper/Meeting.php @@ -81,18 +81,13 @@ public function findPast( int $limit, MeetingTypes $type, ): array { - $qb = $this->getEntityManager()->createQueryBuilder(); - // Use yesterday because a meeting might still take place later on the day $date = new DateTime(); $date->add(DateInterval::createFromDateString('yesterday')); - $qb->select('m, COUNT(d)') - ->from($this->getRepositoryName(), 'm') + $qb = $this->getRepository()->createQueryBuilder('m') ->where('m.date <= :date') ->andWhere('m.type = :type') - ->leftJoin('m.decisions', 'd') - ->groupBy('m') ->orderBy('m.date', 'DESC') ->setParameter('date', $date) ->setParameter('type', $type)