Auto-eliminate non-group participants on group generation (#250)

When generating groups for a tournament (e.g. FIFA World Cup), any
participants in the sport season who were not assigned to a group are
now automatically marked as eliminated (finalPosition = 0) — the same
result as running "Reprocess Eliminations" manually.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chris Parsons 2026-04-01 00:40:55 -07:00 committed by GitHub
parent 005a5a82a7
commit 383315d0c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -824,7 +824,19 @@ export async function action({ request, params }: Route.ActionArgs) {
// Generate the empty knockout bracket structure
await generateBracketFromTemplate(params.eventId, templateId);
return { success: "Groups and knockout bracket structure created successfully" };
// Eliminate participants from this sport season who are not in any group
const allParticipants = await findParticipantsBySportsSeasonId(params.id);
let eliminatedCount = 0;
for (const participant of allParticipants) {
if (!uniqueParticipants.has(participant.id)) {
await setParticipantResult(participant.id, params.id, 0);
eliminatedCount++;
}
}
return {
success: `Groups and knockout bracket structure created successfully${eliminatedCount > 0 ? ` (${eliminatedCount} participant(s) not in any group marked as eliminated)` : ""}`,
};
} catch (error) {
logger.error("Error generating groups:", error);
return {