Skip to content

Commit 98a4e1f

Browse files
committed
bug: fix tournaments being able to udpate stages while not finished / live
1 parent c190bcc commit 98a4e1f

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

hasura/functions/tournaments/can_close_tournament_registration.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RETURNS boolean
66
LANGUAGE plpgsql STABLE
77
AS $$
88
BEGIN
9-
IF tournament.status != 'RegistrationOpen' OR NOT tournament_has_min_teams(tournament) THEN
9+
IF tournament.status != 'RegistrationOpen' THEN
1010
RETURN false;
1111
END IF;
1212

hasura/functions/tournaments/get_stage_team_counts.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BEGIN
1010
WHERE tournament_id = _tournament_id AND "order" = _stage_order;
1111

1212
-- If tournament is in Setup status, use max_teams for bracket planning
13-
IF _tournament_status = 'Setup' THEN
13+
IF _tournament_status != 'Live' AND _tournament_status != 'Finished' THEN
1414
effective_teams := stage_max_teams;
1515
ELSE
1616
IF _stage_order = 1 THEN

hasura/functions/tournaments/update_tournament_stages.sql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ BEGIN
4444
end if;
4545

4646
next_stage_max_teams := COALESCE((select max_teams from tournament_stages ts2 where ts2.tournament_id = _tournament_id and ts2."order" = stage."order" + 1), 1);
47-
teams_per_group := CEIL(effective_teams::float / stage.groups);
47+
48+
RAISE NOTICE 'Stage % : effective_teams=%, next_stage_max_teams=%, groups=%', stage."order", effective_teams, next_stage_max_teams, stage.groups;
49+
teams_per_group := CEIL(effective_teams::float / stage.groups);
4850

4951
IF stage_type = 'RoundRobin' THEN
50-
RAISE NOTICE 'Stage % : RoundRobin detected, teams_per_group=%, groups=%',
51-
stage."order", teams_per_group, stage.groups;
52+
RAISE NOTICE 'Stage % : RoundRobin detected', stage."order";
5253

5354
-- For round robin, we generate all pairings
5455
-- Each group needs (teams_per_group * (teams_per_group - 1)) / 2 matches total

hasura/triggers/tournament_stages.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ BEGIN
199199
FROM tournaments t
200200
WHERE t.id = NEW.tournament_id;
201201

202-
IF tournament_status != 'Setup' THEN
202+
IF tournament_status = 'Live' OR tournament_status = 'Finished' THEN
203203
RAISE EXCEPTION 'Unable to modify stage since the tournament has been started';
204204
END IF;
205205

0 commit comments

Comments
 (0)