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:
parent
005a5a82a7
commit
383315d0c3
1 changed files with 13 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue