Skip to content

Commit

Permalink
fixed showing too much troop participants without troop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Nov 25, 2023
1 parent 8f2321d commit 25cf76d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Participant/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,9 @@ public function showTroopManagement(Request $request, Response $response, Event
[UserStatus::Open],
$event,
),
'troopParticipants' => $this->troopParticipantRepository->getAllWithoutTroop(),
'troopParticipants' => $this->troopParticipantRepository->getAllWithoutTroop(
$event,
),
'caTl' => $event->getEventType()->getContentArbiterTroopLeader(),
'caTp' => $event->getEventType()->getContentArbiterTroopParticipant(),
]);
Expand Down
7 changes: 4 additions & 3 deletions src/Participant/Troop/TroopParticipantRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ public function getFromUser(User $user): TroopParticipant
/**
* @return TroopParticipant[]
*/
public function getAllWithoutTroop(): array
public function getAllWithoutTroop(Event $event): array
{
$troopParticipants = $this->findBy([
'role' => ParticipantRole::TroopParticipant,
'patrol_leader_id' => new Relation(null, 'IS'),
]);

$troopParticipants = array_filter($troopParticipants, function (TroopParticipant $tp): bool {
return $tp->troopLeader === null;
$troopParticipants = array_filter($troopParticipants, function (TroopParticipant $tp) use ($event): bool {
// TODO optimalize event filter
return $tp->troopLeader === null && $tp->getUserButNotNull()->event->id === $event->id;
});

return $troopParticipants;
Expand Down

0 comments on commit 25cf76d

Please sign in to comment.