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
238 changes: 233 additions & 5 deletions generated/schema.graphql

Large diffs are not rendered by default.

198 changes: 181 additions & 17 deletions generated/schema.ts

Large diffs are not rendered by default.

62,264 changes: 31,253 additions & 31,011 deletions generated/types.ts

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions hasura/enums/maps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ insert into e_match_types ("value", "description") values
('Competitive', 'The classic 5 vs 5 competitive experience with full team coordination'),
('Wingman', 'Team up with a friend and compete in fast-paced 2v2 matches'),
('Duel', 'A competitive 1 vs 1 experience, perfect for practicing individual skill'),
('Rush', 'Fast-paced 3 vs 3 matches, pushing room by room'),
('Premier', 'Valve Premier matchmaking — 5 vs 5 with CS Rating'),
('Faceit', 'FACEIT matchmaking — 5 vs 5 imported from FACEIT')
on conflict(value) do update set "description" = EXCLUDED."description";
Expand All @@ -13,6 +14,7 @@ insert into e_game_cfg_types ("value", "description") values
('Competitive', 'Competitive game configuration'),
('Wingman', 'Wingman game configuration'),
('Duel', 'Duel game configuration'),
('Rush', 'Rush game configuration'),
('Global', 'Applies to every match, on top of the type configuration')
on conflict(value) do update set "description" = EXCLUDED."description";

Expand Down Expand Up @@ -59,7 +61,8 @@ WITH map_data AS (
('de_boulder', null, '/img/maps/screenshots/de_boulder.webp', '/img/maps/icons/de_boulder.svg', null),
('de_debris', null, '/img/maps/screenshots/de_debris.webp', '/img/maps/icons/de_debris.svg', null),
('de_eldorado', null, '/img/maps/screenshots/de_eldorado.webp', '/img/maps/icons/de_eldorado.svg', null),
('de_fachwerk', null, '/img/maps/screenshots/de_fachwerk.webp', '/img/maps/icons/de_fachwerk.svg', null)
('de_fachwerk', null, '/img/maps/screenshots/de_fachwerk.webp', '/img/maps/icons/de_fachwerk.svg', null),
('rush_001', null, '/img/maps/screenshots/rush_001.webp', '/img/maps/icons/rush_001.svg', null)

) AS data(name, workshop_map_id, poster, patch, label)
),
Expand Down Expand Up @@ -129,7 +132,10 @@ map_type_config AS (
('de_poseidon', 'Duel', true),
('de_sanctum', 'Duel', true),
('de_debris', 'Duel', false),
('de_eldorado', 'Duel', false)
('de_eldorado', 'Duel', false),

-- Rush maps
('rush_001', 'Rush', true)

) AS data(name, type, active_pool)
),
Expand Down Expand Up @@ -174,6 +180,7 @@ insert into e_map_pool_types ("value", "description") values
('Competitive', '5 vs 5'),
('Wingman', '2 vs 2'),
('Duel', '1 vs 1'),
('Rush', '3 vs 3'),
('Custom', 'Custom')
on conflict(value) do update set "description" = EXCLUDED."description";

Expand All @@ -194,7 +201,7 @@ existing_pools AS (
FROM map_pools mp
LEFT JOIN _map_pool mp_rel ON mp.id = mp_rel.map_pool_id
LEFT JOIN maps m ON mp_rel.map_id = m.id
WHERE mp.seed = true AND mp.type IN ('Competitive', 'Wingman', 'Duel') AND mp.enabled = true
WHERE mp.seed = true AND mp.type IN ('Competitive', 'Wingman', 'Duel', 'Rush') AND mp.enabled = true
GROUP BY mp.id, mp.type
),
pools_to_disable AS (
Expand All @@ -215,7 +222,8 @@ WITH new_rows AS (
FROM (VALUES
('Competitive', true, true),
('Wingman', true, true),
('Duel', true, true)
('Duel', true, true),
('Rush', true, true)
) AS data(type, enabled, seed)
)
INSERT INTO map_pools ("type", "enabled", "seed")
Expand Down Expand Up @@ -248,7 +256,7 @@ begin
WITH pool_ids AS (
SELECT id, type
FROM map_pools
WHERE type IN ('Competitive', 'Wingman', 'Duel') and seed = true and enabled = true
WHERE type IN ('Competitive', 'Wingman', 'Duel', 'Rush') and seed = true and enabled = true
ORDER BY type
)
INSERT INTO _map_pool (map_id, map_pool_id)
Expand All @@ -257,13 +265,25 @@ begin
JOIN pool_ids p ON (
(p.type = 'Competitive' AND m.type = 'Competitive' AND m.active_pool = 'true') OR
(p.type = 'Wingman' AND m.type = 'Wingman' AND m.active_pool = 'true') OR
(p.type = 'Duel' AND m.type = 'Duel' AND m.active_pool = 'true')
(p.type = 'Duel' AND m.type = 'Duel' AND m.active_pool = 'true') OR
(p.type = 'Rush' AND m.type = 'Rush' AND m.active_pool = 'true')
)
WHERE m.deleted_at IS NULL
ON CONFLICT DO NOTHING;

return true;
end if;

-- An enabled seed pool with no maps at all was just created for a new match
-- type, not emptied by an operator, so it is filled even with updates off.
INSERT INTO _map_pool (map_id, map_pool_id)
SELECT m.id, p.id
FROM map_pools p
JOIN maps m ON m.type = p.type AND m.active_pool = 'true' AND m.deleted_at IS NULL
WHERE p.seed = true
AND p.enabled = true
AND NOT EXISTS (SELECT 1 FROM _map_pool mp WHERE mp.map_pool_id = p.id)
ON CONFLICT DO NOTHING;

return false;
end;
Expand Down
15 changes: 11 additions & 4 deletions hasura/functions/demos/persist_imported_demo.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
CREATE OR REPLACE FUNCTION public._import_lineup_1_side(_round int, _mr int)
DROP FUNCTION IF EXISTS public._import_lineup_1_side(int, int);

CREATE OR REPLACE FUNCTION public._import_lineup_1_side(_round int, _mr int, _type text)
RETURNS text
LANGUAGE plpgsql
IMMUTABLE
Expand All @@ -15,6 +17,10 @@ BEGIN
-- lineup_1 starts TERRORIST; GetLineupSide is 0-indexed, round_ticks 1-indexed.
v_r0 := _round - 1;

IF _type = 'Rush' THEN
RETURN 'TERRORIST';
END IF;

IF v_r0 < _mr * 2 THEN
IF v_r0 < _mr THEN
RETURN 'TERRORIST';
Expand Down Expand Up @@ -172,6 +178,7 @@ DECLARE
v_lineup_1_id uuid;
v_lineup_2_id uuid;
v_mr int;
v_type text;
v_tick_rate real;
v_start_time timestamptz;
v_winner_lineup_id uuid;
Expand All @@ -189,7 +196,7 @@ BEGIN
RETURN;
END IF;

SELECT mr INTO v_mr FROM public.match_options WHERE id = v_match_options_id;
SELECT mr, type INTO v_mr, v_type FROM public.match_options WHERE id = v_match_options_id;
v_mr := COALESCE(v_mr, 12);

-- Map for this demo — skill-group ranks (Competitive/Wingman) are per map.
Expand Down Expand Up @@ -227,8 +234,8 @@ BEGIN
with_sides AS (
SELECT
r.*,
public._import_lineup_1_side(r.round, v_mr) AS lineup_1_side,
CASE WHEN public._import_lineup_1_side(r.round, v_mr) = 'TERRORIST' THEN 'CT' ELSE 'TERRORIST' END AS lineup_2_side,
public._import_lineup_1_side(r.round, v_mr, v_type) AS lineup_1_side,
CASE WHEN public._import_lineup_1_side(r.round, v_mr, v_type) = 'TERRORIST' THEN 'CT' ELSE 'TERRORIST' END AS lineup_2_side,
CASE
WHEN winner ILIKE 'T%' THEN 'TERRORIST'
WHEN winner ILIKE 'C%' THEN 'CT'
Expand Down
2 changes: 2 additions & 0 deletions hasura/functions/match/get_match_type_min_players.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ AS $$
BEGIN
IF match_type = 'Competitive' OR match_type = 'Premier' OR match_type = 'Faceit' THEN
RETURN 5;
ELSIF match_type = 'Rush' THEN
RETURN 3;
ELSIF match_type = 'Wingman' THEN
RETURN 2;
ELSIF match_type = 'Duel' THEN
Expand Down
7 changes: 5 additions & 2 deletions hasura/functions/players/get_player_elo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ BEGIN
return jsonb_build_object(
'competitive', get_player_elo_by_type(player, 'Competitive'),
'wingman', get_player_elo_by_type(player, 'Wingman'),
'duel', get_player_elo_by_type(player, 'Duel')
'duel', get_player_elo_by_type(player, 'Duel'),
'rush', get_player_elo_by_type(player, 'Rush')
);
END IF;

Expand All @@ -19,9 +20,11 @@ BEGIN
'competitive', get_player_season_elo_by_type(player, 'Competitive', _active_season_id),
'wingman', get_player_season_elo_by_type(player, 'Wingman', _active_season_id),
'duel', get_player_season_elo_by_type(player, 'Duel', _active_season_id),
'rush', get_player_season_elo_by_type(player, 'Rush', _active_season_id),
'tournament_competitive', get_player_tournament_elo_by_type(player, 'Competitive'),
'tournament_wingman', get_player_tournament_elo_by_type(player, 'Wingman'),
'tournament_duel', get_player_tournament_elo_by_type(player, 'Duel')
'tournament_duel', get_player_tournament_elo_by_type(player, 'Duel'),
'tournament_rush', get_player_tournament_elo_by_type(player, 'Rush')
);
END;
$$;
Expand Down
8 changes: 8 additions & 0 deletions hasura/functions/players/get_player_matches_by_type.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ CREATE OR REPLACE FUNCTION public.get_total_player_wins_duel(player public.playe
LANGUAGE sql STABLE
AS $$ SELECT public.get_total_player_wins_by_type(player, 'Duel'); $$;

CREATE OR REPLACE FUNCTION public.get_total_player_wins_rush(player public.players) RETURNS INT
LANGUAGE sql STABLE
AS $$ SELECT public.get_total_player_wins_by_type(player, 'Rush'); $$;

CREATE OR REPLACE FUNCTION public.get_total_player_losses_competitive(player public.players) RETURNS INT
LANGUAGE sql STABLE
AS $$ SELECT public.get_total_player_losses_by_type(player, 'Competitive'); $$;
Expand All @@ -63,3 +67,7 @@ CREATE OR REPLACE FUNCTION public.get_total_player_losses_wingman(player public.
CREATE OR REPLACE FUNCTION public.get_total_player_losses_duel(player public.players) RETURNS INT
LANGUAGE sql STABLE
AS $$ SELECT public.get_total_player_losses_by_type(player, 'Duel'); $$;

CREATE OR REPLACE FUNCTION public.get_total_player_losses_rush(player public.players) RETURNS INT
LANGUAGE sql STABLE
AS $$ SELECT public.get_total_player_losses_by_type(player, 'Rush'); $$;
3 changes: 2 additions & 1 deletion hasura/functions/players/get_player_peak_elo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ BEGIN
return jsonb_build_object(
'competitive', get_player_peak_elo_by_type(player, 'Competitive'),
'wingman', get_player_peak_elo_by_type(player, 'Wingman'),
'duel', get_player_peak_elo_by_type(player, 'Duel')
'duel', get_player_peak_elo_by_type(player, 'Duel'),
'rush', get_player_peak_elo_by_type(player, 'Rush')
);
END;
$$;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- The rating this tournament's format actually rates on: 2-per-lineup formats
-- run on the Wingman ladder, everything else on Competitive. Season handling
-- mirrors get_player_elo so the number that gates entry is the same number the
-- player sees on their profile.
-- run on the Wingman ladder, 3-per-lineup on Rush, everything else on
-- Competitive. Season handling mirrors get_player_elo so the number that gates
-- entry is the same number the player sees on their profile.
CREATE OR REPLACE FUNCTION public.get_tournament_player_elo(_tournament_id uuid, _player_steam_id bigint)
RETURNS numeric
LANGUAGE plpgsql STABLE
Expand Down Expand Up @@ -29,7 +29,11 @@ BEGIN
public.tournament_max_players_per_lineup(_tournament)
);

_elo_type := CASE WHEN _team_size = 2 THEN 'Wingman' ELSE 'Competitive' END;
_elo_type := CASE
WHEN _team_size = 2 THEN 'Wingman'
WHEN _team_size = 3 THEN 'Rush'
ELSE 'Competitive'
END;

IF public.seasons_enabled() THEN
RETURN public.get_player_season_elo_by_type(_player, _elo_type, public.get_active_season());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ insert_permissions:
- Competitive
- Wingman
- Duel
- Rush
- Premier
- Faceit
set:
Expand Down
16 changes: 16 additions & 0 deletions hasura/metadata/databases/default/tables/public_players.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ computed_fields:
function:
name: get_total_player_losses_duel
schema: public
- name: losses_rush
definition:
function:
name: get_total_player_losses_rush
schema: public
- name: losses_wingman
definition:
function:
Expand Down Expand Up @@ -423,6 +428,11 @@ computed_fields:
function:
name: get_total_player_wins_duel
schema: public
- name: wins_rush
definition:
function:
name: get_total_player_wins_rush
schema: public
- name: wins_wingman
definition:
function:
Expand Down Expand Up @@ -467,6 +477,7 @@ select_permissions:
- losses
- losses_competitive
- losses_duel
- losses_rush
- losses_wingman
- matchmaking_cooldown
- peak_elo
Expand All @@ -475,6 +486,7 @@ select_permissions:
- wins
- wins_competitive
- wins_duel
- wins_rush
- wins_wingman
filter: {}
comment: ""
Expand Down Expand Up @@ -521,6 +533,7 @@ select_permissions:
- losses
- losses_competitive
- losses_duel
- losses_rush
- losses_wingman
- matchmaking_cooldown
- peak_elo
Expand All @@ -529,6 +542,7 @@ select_permissions:
- wins
- wins_competitive
- wins_duel
- wins_rush
- wins_wingman
filter: {}
comment: ""
Expand Down Expand Up @@ -574,6 +588,7 @@ select_permissions:
- losses
- losses_competitive
- losses_duel
- losses_rush
- losses_wingman
- matchmaking_cooldown
- peak_elo
Expand All @@ -582,6 +597,7 @@ select_permissions:
- wins
- wins_competitive
- wins_duel
- wins_rush
- wins_wingman
filter: {}
allow_aggregations: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ select_permissions:
- max_elo
- avg_wingman_elo
- avg_duel_elo
- avg_rush_elo
- avg_faceit_level
- avg_faceit_elo
- avg_premier
Expand Down
1 change: 1 addition & 0 deletions hasura/triggers/draft_games.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BEGIN
NEW.capacity := CASE NEW.type
WHEN 'Duel' THEN 2
WHEN 'Wingman' THEN 4
WHEN 'Rush' THEN 6
ELSE 10
END;

Expand Down
17 changes: 17 additions & 0 deletions hasura/triggers/match_options.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ DECLARE
lan_count int;
region_count int;
BEGIN
IF NEW.type = 'Rush' THEN
NEW.best_of := 1;
NEW.mr := 8;
NEW.overtime := false;
NEW.knife_round := false;
NEW.map_veto := false;
END IF;

SELECT COUNT(DISTINCT region) INTO region_count
FROM servers where enabled = true and type = 'Ranked';

Expand Down Expand Up @@ -63,6 +71,15 @@ BEGIN
RAISE EXCEPTION 'Cannot change match options after match is finished' USING ERRCODE = '22000';
END IF;

-- Forced before the Live/Veto freeze so a pinned value never reads as a change.
IF NEW.type = 'Rush' THEN
NEW.best_of := 1;
NEW.mr := 8;
NEW.overtime := false;
NEW.knife_round := false;
NEW.map_veto := false;
END IF;

IF _match_status != 'PickingPlayers' THEN
IF (NEW.invite_code IS DISTINCT FROM OLD.invite_code) THEN
RAISE EXCEPTION 'Cannot modify invite code' USING ERRCODE = '22000';
Expand Down
4 changes: 2 additions & 2 deletions hasura/views/v_match_lineup_buy_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WITH round_lineup AS (
mmr.lineup_2_money AS enemy_money,
public.normalize_side(mmr.lineup_1_side) AS side,
(public.normalize_side(mmr.winning_side) = public.normalize_side(mmr.lineup_1_side)) AS won,
(mmr.round IN (1, COALESCE(mo.mr, 12) + 1)) AS is_pistol
(mmr.round = 1 OR (mo.type IS DISTINCT FROM 'Rush' AND mmr.round = COALESCE(mo.mr, 12) + 1)) AS is_pistol
FROM public.match_map_rounds mmr
JOIN public.match_maps mm ON mm.id = mmr.match_map_id
JOIN public.matches m ON m.id = mm.match_id
Expand All @@ -21,7 +21,7 @@ WITH round_lineup AS (
mmr.lineup_1_money,
public.normalize_side(mmr.lineup_2_side),
(public.normalize_side(mmr.winning_side) = public.normalize_side(mmr.lineup_2_side)),
(mmr.round IN (1, COALESCE(mo.mr, 12) + 1))
(mmr.round = 1 OR (mo.type IS DISTINCT FROM 'Rush' AND mmr.round = COALESCE(mo.mr, 12) + 1))
FROM public.match_map_rounds mmr
JOIN public.match_maps mm ON mm.id = mmr.match_map_id
JOIN public.matches m ON m.id = mm.match_id
Expand Down
4 changes: 2 additions & 2 deletions hasura/views/v_match_lineup_map_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WITH round_lineup AS (
mmr.lineup_1_money AS own_money,
public.normalize_side(mmr.lineup_1_side) AS side,
(public.normalize_side(mmr.winning_side) = public.normalize_side(mmr.lineup_1_side)) AS won,
(mmr.round IN (1, COALESCE(mo.mr, 12) + 1)) AS is_pistol
(mmr.round = 1 OR (mo.type IS DISTINCT FROM 'Rush' AND mmr.round = COALESCE(mo.mr, 12) + 1)) AS is_pistol
FROM public.match_map_rounds mmr
JOIN public.match_maps mm ON mm.id = mmr.match_map_id
JOIN public.matches m ON m.id = mm.match_id
Expand All @@ -23,7 +23,7 @@ WITH round_lineup AS (
mmr.lineup_2_money,
public.normalize_side(mmr.lineup_2_side),
(public.normalize_side(mmr.winning_side) = public.normalize_side(mmr.lineup_2_side)),
(mmr.round IN (1, COALESCE(mo.mr, 12) + 1))
(mmr.round = 1 OR (mo.type IS DISTINCT FROM 'Rush' AND mmr.round = COALESCE(mo.mr, 12) + 1))
FROM public.match_map_rounds mmr
JOIN public.match_maps mm ON mm.id = mmr.match_map_id
JOIN public.matches m ON m.id = mm.match_id
Expand Down
Loading
Loading