Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hasura/functions/tournaments/assign_teams_to_swiss_pools.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ BEGIN
-- Odd field: pull one team out for a bye (a free win) before pairing so the
-- remaining pools resolve evenly. Prefer a team that has not had a bye yet;
-- among those, the lowest-ranked (fewest wins, most losses).
SELECT COALESCE(SUM(team_count), 0) INTO _total
FROM get_swiss_team_pools(_stage_id, used_teams);
SELECT COALESCE(SUM(p.team_count), 0) INTO _total
FROM get_swiss_team_pools(_stage_id, used_teams) p;

IF _total % 2 = 1 THEN
SELECT vtsr.tournament_team_id,
Expand Down
4 changes: 2 additions & 2 deletions hasura/functions/tournaments/generate_swiss_bracket.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ BEGIN
-- ESEA-style "Swiss group": pair by record but never advance/eliminate — every
-- team plays exactly max_rounds rounds and is ranked in one table. Otherwise the
-- Valve-style system: 3 wins to advance / 3 losses to be eliminated over 5 rounds.
SELECT COALESCE(swiss_no_elimination, false), max_rounds
SELECT COALESCE(ts.swiss_no_elimination, false), ts.max_rounds
INTO _no_elim, _max_rounds_setting
FROM tournament_stages WHERE id = _stage_id;
FROM tournament_stages ts WHERE ts.id = _stage_id;

wins_needed := 3;
IF _no_elim THEN
Expand Down
Loading