Skip to content

Commit

Permalink
filtered out admins from participant lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Apr 27, 2024
1 parent 3a8b828 commit b396e8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/Import/ImportSrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse
$contingent = EventTypeObrok::CONTINGENT_ORG;
}


$skautisUserId = $data['skautis_user_id'];
if (is_numeric($skautisUserId) === false) {
$this->flashMessages->warning('flash.warning.importSrs.skautisUserIdNotNumeric');
Expand All @@ -148,6 +147,7 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse
'Ano' => true,
default => false,
};

$participant = null;
if ($existingUser === null) {
$existingUser = $this->userService->createSkautisUser(
Expand All @@ -156,11 +156,10 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse
$email,
$userStatus,
);

} else {
$participant = $this->participantRepository->findParticipantFromUser($existingUser);

}

return $this->istService->createIstPayment(
$existingUser,
$event,
Expand Down
4 changes: 2 additions & 2 deletions src/Participant/Ist/IstService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public function createIstPayment(
string $swift,
DateTimeImmutable $due,
): Participant {
if ($participant == null) {
if ($participant === null) {
$participant = new Participant();
}
$participant->user = $user;
$participant->role = ParticipantRole::Ist;
$participant->role = ParticipantRole::Ist; // TODO fix case with TL/PL having troop participants/patrol patrol participants
$participant->contingent = $contingent;
$participant->firstName = $firstName;
$participant->lastName = $lastName;
Expand Down
10 changes: 8 additions & 2 deletions src/Participant/ParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getAllParticipantsWithStatus(
$qb->join('user')->as('u')->on('u.id = participant.user_id');

$qb->where('participant.role IN %in', $roles);
$qb->where('u.role = %s', UserRole::Participant);
$qb->where('u.status IN %in', $statuses);
$qb->where('u.event_id = %i', $event->id);

Expand Down Expand Up @@ -102,6 +103,7 @@ public function getParticipantsCount(
$qb->join('user')->as('u')->on('u.id = participant.user_id');

$qb->where('participant.role IN %in', $roles);
$qb->where('u.role = %s', UserRole::Participant);
$qb->where('u.status IN %in', $statuses);
$qb->where('u.event_id = %i', $event->id);

Expand Down Expand Up @@ -208,6 +210,7 @@ public function getParticipantsForEntry(Event $event): array
$qb->join('user')->as('u')->on('u.id = participant.user_id');
$qb->leftJoin('deal')->as('d')->on('participant.id = d.participant_id')->and('d.slug = %s', 'sfh');

$qb->where('u.role = %s', UserRole::Participant);
$qb->where('u.status = %s', UserStatus::Paid);
$qb->where('u.event_id = %i', $event->id);

Expand Down Expand Up @@ -274,9 +277,10 @@ public function getIstArrivalStatistic(
$qb = $this->connection->select('date(participant.arrival_date) as ad, COUNT(*)')->from($this->getTable());
$qb->join('user')->as('u')->on('u.id = participant.user_id');

$qb->where('u.event_id = %i', $event->id);
$qb->where('participant.role = %s', ParticipantRole::Ist);
$qb->where('u.role = %s', UserRole::Participant);
$qb->where('u.status = %s', UserStatus::Paid);
$qb->where('u.event_id = %i', $event->id);

$qb->groupBy('date(participant.arrival_date)');
$qb->orderBy('date(participant.arrival_date)');
Expand All @@ -296,8 +300,9 @@ public function getFoodStatistic(
$qb = $this->connection->select('participant.food_preferences as f, COUNT(*)')->from($this->getTable());
$qb->join('user')->as('u')->on('u.id = participant.user_id');

$qb->where('u.event_id = %i', $event->id);
$qb->where('u.role = %s', UserRole::Participant);
$qb->where('u.status = %s', UserStatus::Paid);
$qb->where('u.event_id = %i', $event->id);

$qb->groupBy('participant.food_preferences');
$qb->orderBy('participant.food_preferences');
Expand All @@ -322,6 +327,7 @@ public function getStatistic(
$qb->where('participant.contingent = %s', $contingent);
}

$qb->where('u.role = %s', UserRole::Participant);
$qb->groupBy('u.status');

$rows = $qb->fetchPairs('status', 'count');
Expand Down

0 comments on commit b396e8f

Please sign in to comment.