Skip to content

Commit

Permalink
[Admin] fix event author filter (#11367)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jan 27, 2025
1 parent 28a1d9b commit ce1ca47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Admin/EventAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
'show_filter' => true,
'field_type' => DateRangePickerType::class,
])
->add('organizer.firstName', null, [
->add('author.firstName', null, [
'label' => 'Prénom de l\'organisateur',
'show_filter' => true,
])
->add('organizer.lastName', null, [
->add('author.lastName', null, [
'label' => 'Nom de l\'organisateur',
'show_filter' => true,
])
Expand Down
19 changes: 11 additions & 8 deletions src/Repository/EventRegistrationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,19 @@ public function isAlreadyRegistered(string $email, BaseEvent $event): bool

public function countEventParticipantsWithoutCreator(BaseEvent $event): int
{
return (int) $this->createQueryBuilder('event_registration')
->select('COUNT(1)')
->leftJoin('event_registration.adherent', 'adherent')
->where('event_registration.event = :event AND (adherent.uuid IS NULL OR adherent.uuid != :organiser_uuid)')
->andWhere('event_registration.emailAddress IS NOT NULL')
$qb = $this->createQueryBuilder('er')
->select('COUNT(DISTINCT er.id)')
->leftJoin('er.adherent', 'a')
->where('er.event = :event')
->andWhere('er.emailAddress IS NOT NULL')
->setParameter('event', $event)
->setParameter('organiser_uuid', $event->getOrganizer()->getUuid()->toString())
->getQuery()
->getSingleScalarResult()
;

if ($author = $event->getAuthor()) {
$qb->andWhere('a IS NULL OR a != :author')->setParameter('author', $author);
}

return $qb->getQuery()->getSingleScalarResult();
}

private function createEventRegistrationQueryBuilder(string $eventUuid): QueryBuilder
Expand Down

0 comments on commit ce1ca47

Please sign in to comment.