Skip to content

Commit a46d305

Browse files
committed
refactor: replace auto_cancel with match_mode + track_cancellation
Address PR review: redesign auto_cancel boolean into two fields - match_mode (admin/auto enum) and track_cancellation (boolean). Revert check_tournament_finished guard, remove pause-clearing logic from match_maps trigger, squash migrations into clean schema.
1 parent d365104 commit a46d305

17 files changed

Lines changed: 49 additions & 79 deletions

File tree

hasura/functions/tournaments/check_tournament_finished.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ BEGIN
2222
if unfinished_brackets = 0 then
2323
update tournaments
2424
set status = 'Finished'
25-
where id = _tournament_id
26-
and status not in ('Cancelled', 'CancelledMinTeams');
25+
where id = _tournament_id;
2726
end if;
2827
END;
2928
$$;

hasura/functions/tournaments/clone_match_options_with_best_of.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BEGIN
3030
map_veto, timeout_setting, tech_timeout_setting, map_pool_id, type,
3131
regions, prefer_dedicated_server, invite_code, lobby_access,
3232
region_veto, ready_setting, check_in_setting, default_models, tv_delay,
33-
auto_cancel
33+
track_cancellation, match_mode
3434
) VALUES (
3535
match_options_record.overtime, match_options_record.knife_round,
3636
match_options_record.mr, _target_best_of,
@@ -42,7 +42,7 @@ BEGIN
4242
match_options_record.lobby_access, match_options_record.region_veto,
4343
match_options_record.ready_setting, match_options_record.check_in_setting,
4444
match_options_record.default_models, match_options_record.tv_delay,
45-
match_options_record.auto_cancel
45+
match_options_record.track_cancellation, match_options_record.match_mode
4646
)
4747
RETURNING id INTO cloned_id;
4848

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
table:
2+
name: e_match_mode
3+
schema: public
4+
is_enum: true
5+
select_permissions:
6+
- role: guest
7+
permission:
8+
columns:
9+
- description
10+
- value
11+
filter: {}
12+
comment: ""

hasura/metadata/databases/default/tables/public_match_options.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ insert_permissions:
4949
permission:
5050
check: {}
5151
columns:
52-
- auto_cancel
5352
- best_of
5453
- check_in_setting
5554
- coaches
@@ -58,6 +57,7 @@ insert_permissions:
5857
- lobby_access
5958
- map_pool_id
6059
- map_veto
60+
- match_mode
6161
- mr
6262
- number_of_substitutes
6363
- overtime
@@ -67,21 +67,22 @@ insert_permissions:
6767
- regions
6868
- tech_timeout_setting
6969
- timeout_setting
70+
- track_cancellation
7071
- tv_delay
7172
- type
7273
comment: ""
7374
- role: user
7475
permission:
7576
check: {}
7677
columns:
77-
- auto_cancel
7878
- best_of
7979
- coaches
8080
- default_models
8181
- knife_round
8282
- lobby_access
8383
- map_pool_id
8484
- map_veto
85+
- match_mode
8586
- mr
8687
- number_of_substitutes
8788
- overtime
@@ -91,14 +92,14 @@ insert_permissions:
9192
- regions
9293
- tech_timeout_setting
9394
- timeout_setting
95+
- track_cancellation
9496
- tv_delay
9597
- type
9698
comment: ""
9799
select_permissions:
98100
- role: guest
99101
permission:
100102
columns:
101-
- auto_cancel
102103
- best_of
103104
- check_in_setting
104105
- coaches
@@ -108,6 +109,7 @@ select_permissions:
108109
- lobby_access
109110
- map_pool_id
110111
- map_veto
112+
- match_mode
111113
- mr
112114
- number_of_substitutes
113115
- overtime
@@ -117,6 +119,7 @@ select_permissions:
117119
- regions
118120
- tech_timeout_setting
119121
- timeout_setting
122+
- track_cancellation
120123
- tv_delay
121124
- type
122125
filter: {}
@@ -125,7 +128,6 @@ update_permissions:
125128
- role: match_organizer
126129
permission:
127130
columns:
128-
- auto_cancel
129131
- best_of
130132
- check_in_setting
131133
- coaches
@@ -134,6 +136,7 @@ update_permissions:
134136
- lobby_access
135137
- map_pool_id
136138
- map_veto
139+
- match_mode
137140
- mr
138141
- number_of_substitutes
139142
- overtime
@@ -143,6 +146,7 @@ update_permissions:
143146
- regions
144147
- tech_timeout_setting
145148
- timeout_setting
149+
- track_cancellation
146150
- tv_delay
147151
- type
148152
filter:
@@ -183,14 +187,14 @@ update_permissions:
183187
- role: user
184188
permission:
185189
columns:
186-
- auto_cancel
187190
- best_of
188191
- coaches
189192
- default_models
190193
- knife_round
191194
- lobby_access
192195
- map_pool_id
193196
- map_veto
197+
- match_mode
194198
- mr
195199
- number_of_substitutes
196200
- overtime
@@ -200,6 +204,7 @@ update_permissions:
200204
- regions
201205
- tech_timeout_setting
202206
- timeout_setting
207+
- track_cancellation
203208
- tv_delay
204209
- type
205210
filter:

hasura/metadata/databases/default/tables/tables.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- "!include public_e_lobby_player_status.yaml"
1212
- "!include public_e_map_pool_types.yaml"
1313
- "!include public_e_match_map_status.yaml"
14+
- "!include public_e_match_mode.yaml"
1415
- "!include public_e_match_status.yaml"
1516
- "!include public_e_match_types.yaml"
1617
- "!include public_e_notification_types.yaml"

hasura/migrations/default/1772556082000_create_e_auto_cancel_mode/down.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

hasura/migrations/default/1772556082000_create_e_auto_cancel_mode/up.sql

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS public.e_match_mode;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE IF NOT EXISTS public.e_match_mode (
2+
value text NOT NULL PRIMARY KEY,
3+
description text NOT NULL
4+
);
5+
INSERT INTO e_match_mode ("value", "description") VALUES
6+
('admin', 'Match must be scheduled and started by an admin user'),
7+
('auto', 'Match is automatically scheduled by the system')
8+
ON CONFLICT(value) DO UPDATE SET "description" = EXCLUDED."description";

hasura/migrations/default/1772556083000_add_auto_cancel_mode_to_match_options/down.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)