Skip to content
Merged
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.

57,532 changes: 30,740 additions & 26,792 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"
47 changes: 42 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,58 @@ 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. A parentless WB bracket is NOT enough on its
-- own: a DE stage that passes 2+ teams to a next stage never creates a GF,
-- leaving each group's WB final parentless too — only the real GF has an
-- LB feeder as a child. 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'
AND EXISTS (
SELECT 1
FROM tournament_brackets lb
WHERE lb.parent_bracket_id = tb.id
AND lb.path = 'LB'
);

-- Clamp below the win threshold: at or above it the winner-bracket team
-- would take the match on the first finished map, even one it lost.
lineup_1_wins := LEAST(
COALESCE(final_advantage, 0),
CEIL(match_best_of / 2.0)::int - 1
);

-- 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 +92,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 +101,4 @@ BEGIN
END IF;
RETURN;
END;
$$;
$$;
257 changes: 257 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,257 @@
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:
_and:
- enabled:
_eq: true
- required_role:
_is_null: 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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
- verified_user
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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
- verified_user
- streamer
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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
- verified_user
- streamer
- moderator
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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
- verified_user
- streamer
- moderator
- match_organizer
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:
_and:
- enabled:
_eq: true
- _or:
- required_role:
_is_null: true
- required_role:
_in:
- user
- verified_user
- streamer
- moderator
- match_organizer
- tournament_organizer
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: ""
Loading
Loading