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
6,010 changes: 6,009 additions & 1 deletion generated/schema.graphql

Large diffs are not rendered by default.

6,914 changes: 6,870 additions & 44 deletions generated/schema.ts

Large diffs are not rendered by default.

82,024 changes: 45,189 additions & 36,835 deletions generated/types.ts

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion hasura/enums/notification-types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ INSERT INTO e_notification_types ("value", "description") VALUES
('MatchChatMessage', 'A new message in a match''s chat'),
('TournamentCreated', 'Registration opened for a tournament'),
('TournamentReminder', 'A tournament you are registered for starts soon'),
('TournamentCheckInOpen', 'Check-in has opened for a tournament you are registered for'),
('TournamentCheckInClosing', 'Check-in for your tournament closes soon'),
('TournamentCheckInMissed', 'Your team missed check-in and was not seeded'),
('NewsPublished', 'A news article was published'),
('TeamInvite', 'You were invited to a team'),
('TournamentTeamInvite', 'You were invited to play in a tournament'),
('TournamentInvite', 'You were invited to register for a tournament'),
('DraftInvite', 'You were invited to a draft lobby'),
('MatchStatsReady', 'Stats for a match you played are ready'),
('ClipReady', 'A clip you requested finished rendering'),
Expand All @@ -44,6 +48,7 @@ INSERT INTO e_notification_types ("value", "description") VALUES
('SeasonEnded', 'A season has ended'),
('UtilityPracticeInvite', 'You were invited to a utility practice session'),
('UtilityPracticeReady', 'Your utility practice server is ready'),
('UtilityDriftScanFinished', 'A utility drift scan finished')
('UtilityDriftScanFinished', 'A utility drift scan finished'),
('TournamentPartySignup', 'Your lobby was signed up for a tournament as a free agent party')
ON CONFLICT("value") DO UPDATE
SET "description" = EXCLUDED."description";
5 changes: 5 additions & 0 deletions hasura/enums/sanction-scopes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into e_sanction_scopes ("value", "description") values
('matchmaking', 'Bars the player from queueing and from draft lobbies'),
('tournaments', 'Bars the player from joining a tournament roster or free agent pool'),
('both', 'Bars the player from matchmaking and tournaments')
on conflict(value) do update set "description" = EXCLUDED."description"
17 changes: 17 additions & 0 deletions hasura/enums/sanction-sources.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- The default_* columns are the shipped policy, not operator data: the settings
-- rows an operator edits are seeded from these once and never reset, so a
-- release is free to correct a default here without touching a live install.
insert into e_sanction_sources
("value", "description", default_enabled, default_threshold, default_window_days, default_durations, default_scope, writes_platform_ban)
values
('match_abandon', 'A player left or never connected to a match they were rostered for', true, 1, 7, '10,60,120,240,480,960,1920', 'matchmaking', false),
('vac_ban', 'Steam reports a VAC or game ban on the player''s account', true, 1, 0, '0', 'both', true),
('tournament_no_show', 'A team missed a required tournament check-in', true, 3, 30, '10080', 'tournaments', false)
on conflict(value) do update set
"description" = EXCLUDED."description",
default_enabled = EXCLUDED.default_enabled,
default_threshold = EXCLUDED.default_threshold,
default_window_days = EXCLUDED.default_window_days,
default_durations = EXCLUDED.default_durations,
default_scope = EXCLUDED.default_scope,
writes_platform_ban = EXCLUDED.writes_platform_ban
6 changes: 6 additions & 0 deletions hasura/enums/tournament-free-agent-statuses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
insert into e_tournament_free_agent_statuses ("value", "description") values
('registered', 'Signed up and waiting for the draft'),
('drafted', 'Placed on a drafted team'),
('waitlisted', 'Did not make the cut; first in line if a slot opens'),
('withdrawn', 'Left the free agent pool')
on conflict(value) do update set "description" = EXCLUDED."description"
5 changes: 5 additions & 0 deletions hasura/enums/tournament-registration-types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
insert into e_tournament_registration_types ("value", "description") values
('teams', 'Only pre-formed teams may register'),
('free_agents', 'Only individual players may register; teams are drafted from the pool'),
('both', 'Pre-formed teams and individual free agents may both register')
on conflict(value) do update set "description" = EXCLUDED."description"
1 change: 1 addition & 0 deletions hasura/enums/tournament-statuses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ insert into e_tournament_status ("value", "description") values
('Setup', 'Setup'),
('RegistrationOpen', 'Registration Open'),
('RegistrationClosed', 'Registration Closed'),
('CheckInReview', 'Check-in closed with teams missing; held for organizer review'),
('Live', 'Live'),
('Cancelled', 'Cancelled'),
('CancelledMinTeams', 'Cancelled because it did not meet minimum number of teams'),
Expand Down
23 changes: 23 additions & 0 deletions hasura/functions/generate_secure_invite_code.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Crockford base32 over gen_random_bytes: 10 chars, 50 bits, no ambiguous
-- glyphs, 256 % 32 == 0 so the modulo is unbiased. The generator for any code
-- handed out on a public link.
--
-- 1885000000000_tournament_invite_codes seeds a copy when it is missing --
-- migrations run before this phase, so a column DEFAULT calling it would not
-- resolve on a fresh install. This file stays the definition that is maintained.
CREATE OR REPLACE FUNCTION public.generate_secure_invite_code() RETURNS text
LANGUAGE plpgsql
VOLATILE
AS $fn$
DECLARE
alphabet constant text := '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
source bytea := gen_random_bytes(10);
code text := '';
i int;
BEGIN
FOR i IN 0..9 LOOP
code := code || substr(alphabet, (get_byte(source, i) % 32) + 1, 1);
END LOOP;
RETURN code;
END;
$fn$;
44 changes: 15 additions & 29 deletions hasura/functions/players/get_player_matchmaking_cooldown.sql
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
-- The matchmaking half of the sanctions policy. The escalation ladder, the decay
-- window and whether this fires at all now live in settings (see
-- hasura/functions/sanctions/sanction_policy.sql); the shipped defaults for
-- match_abandon reproduce exactly what was hardcoded here before -- a 7 day
-- window and the 10/60/120/240/480/960/1920 minute ladder, counted from the last
-- abandon -- so turning the policy on changes nothing until an operator edits it.
--
-- The window is still counted rather than the rows being deleted. The escalation
-- used to be forgiven by CleanAbandonedMatches deleting the rows, which made the
-- record too short-lived to recompute elo from: a leaver penalty applied at match
-- time silently vanished from any later recompute.
CREATE OR REPLACE FUNCTION get_player_matchmaking_cooldown(player public.players, hasura_session json)
RETURNS TIMESTAMP WITH TIME ZONE AS $$
DECLARE
abandoned_count INTEGER;
last_abandoned_time TIMESTAMP WITH TIME ZONE;
minutes_since_last_abandoned INTEGER;
cooldown_duration INTEGER;
cooldown_time TIMESTAMP WITH TIME ZONE;
cooldown_durations INTEGER[] := ARRAY[10, 60, 120, 240, 480, 960, 1920];
BEGIN

IF (hasura_session ->> 'x-hasura-user-id')::bigint != player.steam_id::bigint THEN
RETURN NULL;
END IF;

-- Windowed rather than counting every row ever. The escalation used to be
-- forgiven by CleanAbandonedMatches deleting the rows, which made the
-- record too short-lived to recompute elo from -- a leaver penalty applied
-- at match time silently vanished from any later recompute. The window
-- keeps the same forgiveness while the rows stay put.
SELECT COUNT(*) INTO abandoned_count
FROM abandoned_matches
WHERE steam_id = player.steam_id
AND abandoned_at > NOW() - INTERVAL '7 days';
cooldown_time := public.player_sanction_expiry(player.steam_id, 'matchmaking');

IF abandoned_count > 0 THEN
SELECT abandoned_at
INTO last_abandoned_time
FROM abandoned_matches
WHERE steam_id = player.steam_id
AND abandoned_at > NOW() - INTERVAL '7 days'
ORDER BY abandoned_at DESC
LIMIT 1;

cooldown_time := last_abandoned_time + (cooldown_durations[LEAST(abandoned_count, array_length(cooldown_durations, 1))] * INTERVAL '1 minute');

IF cooldown_time > NOW() THEN
RETURN cooldown_time;
END IF;
IF cooldown_time > NOW() THEN
RETURN cooldown_time;
END IF;

RETURN NULL;
END;
$$ LANGUAGE plpgsql stable;
$$ LANGUAGE plpgsql stable;
Loading
Loading