Skip to content

Commit 65e357a

Browse files
authored
bug: fix tournament scheduling (#162)
1 parent 04ba5ba commit 65e357a

7 files changed

Lines changed: 440 additions & 185 deletions

File tree

hasura/functions/tournaments/reset_tournament_match.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ BEGIN
211211
DELETE FROM tournament_trophies
212212
WHERE tournament_id = source_tournament_id;
213213
END IF;
214+
214215
END IF;
215216
END;
216217
$$;

hasura/functions/tournaments/schedule_tournament_match.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ CREATE OR REPLACE FUNCTION public.schedule_tournament_match(bracket public.tourn
6161
_match_options_id := tournament.match_options_id;
6262
END IF;
6363

64-
-- Enforce match_mode: skip auto-scheduling for admin-only matches
64+
-- Enforce match_mode:
65+
-- - admin mode requires an explicit organizer-set schedule on the bracket
66+
-- - other modes can continue existing auto-scheduling behavior
6567
DECLARE
6668
_match_mode text;
6769
BEGIN
6870
SELECT mo.match_mode INTO _match_mode
6971
FROM match_options mo WHERE mo.id = _match_options_id;
7072

71-
IF _match_mode = 'admin' THEN
72-
RAISE NOTICE 'schedule_tournament_match: bracket % is admin-mode, skipping auto-schedule', bracket.id;
73+
IF _match_mode = 'admin' AND bracket.scheduled_at IS NULL THEN
74+
RAISE NOTICE 'schedule_tournament_match: bracket % is admin-mode without schedule, skipping auto-schedule', bracket.id;
7375
RETURN NULL;
7476
END IF;
7577
END;

0 commit comments

Comments
 (0)