diff --git a/hasura/functions/tournaments/assign_teams_to_swiss_pools.sql b/hasura/functions/tournaments/assign_teams_to_swiss_pools.sql index 4c909a2c..16c216b4 100644 --- a/hasura/functions/tournaments/assign_teams_to_swiss_pools.sql +++ b/hasura/functions/tournaments/assign_teams_to_swiss_pools.sql @@ -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, diff --git a/hasura/functions/tournaments/generate_swiss_bracket.sql b/hasura/functions/tournaments/generate_swiss_bracket.sql index b1656dca..5422474b 100644 --- a/hasura/functions/tournaments/generate_swiss_bracket.sql +++ b/hasura/functions/tournaments/generate_swiss_bracket.sql @@ -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