Skip to content
Closed
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
2,824 changes: 2,824 additions & 0 deletions generated/schema.graphql

Large diffs are not rendered by default.

2,895 changes: 2,833 additions & 62 deletions generated/schema.ts

Large diffs are not rendered by default.

66,409 changes: 31,189 additions & 35,220 deletions generated/types.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions hasura/enums/tournament-categories.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SET check_function_bodies = false;

insert into e_tournament_categories ("value", "description") values
('LAN', 'LAN'),
('LocationEvent', 'Location Event'),
('OnlineEvent', 'Online Event'),
('League', 'League')
on conflict(value) do update set "description" = EXCLUDED."description"
33 changes: 28 additions & 5 deletions hasura/functions/match/update_match_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DECLARE
match_winning_lineup_id UUID;
lineup_1_wins INT := 0;
lineup_2_wins INT := 0;
final_advantage INT := 0;
match_map public.match_maps;
BEGIN
-- Retrieve match best_of value
Expand All @@ -21,22 +22,44 @@ BEGIN
INNER JOIN match_options mo
ON mo.id = m.match_options_id
WHERE m.id = _match_map.match_id;

IF (_match_map.status = 'Finished') THEN
-- Get current match status and lineups
SELECT status
INTO current_match_status
FROM matches
WHERE id = _match_map.match_id;

IF current_match_status = 'Forfeit' OR current_match_status = 'Surrendered' THEN
IF current_match_status IN ('Finished', 'Forfeit', 'Surrendered', 'Canceled', 'Tie') THEN
RETURN;
END IF;

-- Loop through match maps and calculate wins

-- Winner-bracket advantage: when this match is the grand final of a
-- double-elimination stage, the winner-bracket team starts with a map-point
-- head start. Stays 0 (inert) for every other match.
-- The grand final is stored as path 'WB' at round wb_rounds+1 with no parent
-- (generate_double_elimination_bracket); 'GF' is only a round_best_of settings
-- key, never a stored path. assign_team_to_bracket_slot orders the WB feeder
-- ahead of the LB feeder, so the winner-bracket team is always slot 1 /
-- tournament_team_id_1, which schedule_tournament_match maps to lineup_1.
SELECT COALESCE(ts.final_map_advantage, 0)
INTO final_advantage
FROM tournament_brackets tb
INNER JOIN tournament_stages ts ON ts.id = tb.tournament_stage_id
WHERE tb.match_id = _match_map.match_id
AND ts.type = 'DoubleElimination'
AND tb.parent_bracket_id IS NULL
AND COALESCE(tb.path, 'WB') = 'WB';

lineup_1_wins := COALESCE(final_advantage, 0);

-- Only Finished maps count: an in-progress map's latest round snapshot
-- would otherwise credit a map win to whoever is momentarily ahead.
FOR match_map IN
SELECT *
FROM match_maps
WHERE match_id = _match_map.match_id
AND status = 'Finished'
LOOP
map_lineup_1_score := lineup_1_score(match_map);
map_lineup_2_score := lineup_2_score(match_map);
Expand All @@ -55,7 +78,7 @@ BEGIN
ELSE
match_winning_lineup_id := match_lineup_2_id;
END IF;
IF lineup_1_wins = CEIL(match_best_of / 2.0) OR lineup_2_wins = CEIL(match_best_of / 2.0) THEN
IF lineup_1_wins >= CEIL(match_best_of / 2.0) OR lineup_2_wins >= CEIL(match_best_of / 2.0) THEN
-- Update match status and winning lineup
UPDATE matches
SET status = 'Finished', winning_lineup_id = match_winning_lineup_id
Expand All @@ -64,4 +87,4 @@ BEGIN
END IF;
RETURN;
END;
$$;
$$;
197 changes: 197 additions & 0 deletions hasura/metadata/databases/default/tables/public_custom_pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
table:
name: custom_pages
schema: public
insert_permissions:
- role: administrator
permission:
check: {}
columns:
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
comment: ""
select_permissions:
- role: administrator
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
- created_at
- updated_at
filter: {}
allow_aggregations: true
comment: ""
- role: guest
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: user
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: verified_user
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: streamer
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: moderator
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: match_organizer
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
- role: tournament_organizer
permission:
columns:
- id
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter:
enabled:
_eq: true
comment: ""
update_permissions:
- role: administrator
permission:
columns:
- slug
- title
- icon
- remote_entry_url
- remote_scope
- exposed_module
- required_role
- enabled
- is_default
- nav_group
- nav_order
filter: {}
check: {}
comment: ""
delete_permissions:
- role: administrator
permission:
filter: {}
comment: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
table:
name: e_tournament_categories
schema: public
is_enum: true
array_relationships:
- name: tournament_categories
using:
foreign_key_constraint_on:
column: category
table:
name: tournament_categories
schema: public
select_permissions:
- role: guest
permission:
columns:
- description
- value
filter: {}
comment: ""
10 changes: 10 additions & 0 deletions hasura/metadata/databases/default/tables/public_match_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ insert_permissions:
- auto_cancellation
- tv_delay
- type
- halftime_pausematch
- round_restart_delay
comment: ""
- role: user
permission:
Expand All @@ -93,6 +95,8 @@ insert_permissions:
- timeout_setting
- tv_delay
- type
- halftime_pausematch
- round_restart_delay
comment: ""
select_permissions:
- role: guest
Expand Down Expand Up @@ -121,6 +125,8 @@ select_permissions:
- auto_cancellation
- tv_delay
- type
- halftime_pausematch
- round_restart_delay
filter: {}
comment: ""
update_permissions:
Expand Down Expand Up @@ -149,6 +155,8 @@ update_permissions:
- auto_cancellation
- tv_delay
- type
- halftime_pausematch
- round_restart_delay
filter:
_or:
- matches:
Expand Down Expand Up @@ -204,6 +212,8 @@ update_permissions:
- timeout_setting
- tv_delay
- type
- halftime_pausematch
- round_restart_delay
filter:
_or:
- matches:
Expand Down
14 changes: 14 additions & 0 deletions hasura/metadata/databases/default/tables/public_team_roster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,17 @@ event_triggers:
num_retries: 6
timeout_sec: 60
webhook: '{{HASURA_GRAPHQL_EVENT_HOOK}}'
- name: tournament_org_roster_events
definition:
delete:
columns: '*'
enable_manual: true
insert:
columns: '*'
update:
columns: '*'
retry_conf:
interval_sec: 10
num_retries: 6
timeout_sec: 60
webhook: '{{HASURA_GRAPHQL_EVENT_HOOK}}'
2 changes: 2 additions & 0 deletions hasura/metadata/databases/default/tables/public_teams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ select_permissions:
- avatar_url
- captain_steam_id
- id
- is_organization
- name
- owner_steam_id
- short_name
Expand All @@ -139,6 +140,7 @@ update_permissions:
permission:
columns:
- captain_steam_id
- is_organization
- name
- owner_steam_id
- short_name
Expand Down
Loading
Loading