Skip to content

Commit

Permalink
fix: unnecessary decision counting while retrieving past meetings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Oct 20, 2024
1 parent c56837c commit 1053574
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
18 changes: 9 additions & 9 deletions module/Decision/src/Controller/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
];

Expand Down
7 changes: 1 addition & 6 deletions module/Decision/src/Mapper/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1053574

Please sign in to comment.