Skip to content

Commit 89333d6

Browse files
authored
feature: add computed joined tournament (#109)
1 parent 8ad4b77 commit 89333d6

9 files changed

Lines changed: 71 additions & 14 deletions

File tree

generated/schema.graphql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45824,6 +45824,11 @@ type tournaments {
4582445824
A computed field, executes function "is_tournament_organizer"
4582545825
"""
4582645826
is_organizer: Boolean
45827+
45828+
"""
45829+
A computed field, executes function "joined_tournament"
45830+
"""
45831+
joined_tournament: Boolean
4582745832
match_options_id: uuid!
4582845833

4582945834
"""
@@ -46158,6 +46163,7 @@ input tournaments_bool_exp {
4615846163
has_min_teams: Boolean_comparison_exp
4615946164
id: uuid_comparison_exp
4616046165
is_organizer: Boolean_comparison_exp
46166+
joined_tournament: Boolean_comparison_exp
4616146167
match_options_id: uuid_comparison_exp
4616246168
max_players_per_lineup: Int_comparison_exp
4616346169
min_players_per_lineup: Int_comparison_exp
@@ -46372,6 +46378,7 @@ input tournaments_order_by {
4637246378
has_min_teams: order_by
4637346379
id: order_by
4637446380
is_organizer: order_by
46381+
joined_tournament: order_by
4637546382
match_options_id: order_by
4637646383
max_players_per_lineup: order_by
4637746384
min_players_per_lineup: order_by

generated/schema.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12903,6 +12903,8 @@ export interface tournaments {
1290312903
id: Scalars['uuid']
1290412904
/** A computed field, executes function "is_tournament_organizer" */
1290512905
is_organizer: (Scalars['Boolean'] | null)
12906+
/** A computed field, executes function "joined_tournament" */
12907+
joined_tournament: (Scalars['Boolean'] | null)
1290612908
match_options_id: Scalars['uuid']
1290712909
/** A computed field, executes function "tournament_max_players_per_lineup" */
1290812910
max_players_per_lineup: (Scalars['Int'] | null)
@@ -41056,6 +41058,8 @@ export interface tournamentsGenqlSelection{
4105641058
id?: boolean | number
4105741059
/** A computed field, executes function "is_tournament_organizer" */
4105841060
is_organizer?: boolean | number
41061+
/** A computed field, executes function "joined_tournament" */
41062+
joined_tournament?: boolean | number
4105941063
match_options_id?: boolean | number
4106041064
/** A computed field, executes function "tournament_max_players_per_lineup" */
4106141065
max_players_per_lineup?: boolean | number
@@ -41254,7 +41258,7 @@ export interface tournaments_avg_order_by {organizer_steam_id?: (order_by | null
4125441258

4125541259

4125641260
/** Boolean expression to filter rows from the table "tournaments". All fields are combined with a logical 'AND'. */
41257-
export interface tournaments_bool_exp {_and?: (tournaments_bool_exp[] | null),_not?: (tournaments_bool_exp | null),_or?: (tournaments_bool_exp[] | null),admin?: (players_bool_exp | null),can_cancel?: (Boolean_comparison_exp | null),can_close_registration?: (Boolean_comparison_exp | null),can_join?: (Boolean_comparison_exp | null),can_open_registration?: (Boolean_comparison_exp | null),can_start?: (Boolean_comparison_exp | null),created_at?: (timestamptz_comparison_exp | null),description?: (String_comparison_exp | null),discord_notifications_enabled?: (Boolean_comparison_exp | null),discord_notify_Canceled?: (Boolean_comparison_exp | null),discord_notify_Finished?: (Boolean_comparison_exp | null),discord_notify_Forfeit?: (Boolean_comparison_exp | null),discord_notify_Live?: (Boolean_comparison_exp | null),discord_notify_MapPaused?: (Boolean_comparison_exp | null),discord_notify_PickingPlayers?: (Boolean_comparison_exp | null),discord_notify_Scheduled?: (Boolean_comparison_exp | null),discord_notify_Surrendered?: (Boolean_comparison_exp | null),discord_notify_Tie?: (Boolean_comparison_exp | null),discord_notify_Veto?: (Boolean_comparison_exp | null),discord_notify_WaitingForCheckIn?: (Boolean_comparison_exp | null),discord_notify_WaitingForServer?: (Boolean_comparison_exp | null),discord_role_id?: (String_comparison_exp | null),discord_webhook?: (String_comparison_exp | null),e_tournament_status?: (e_tournament_status_bool_exp | null),has_min_teams?: (Boolean_comparison_exp | null),id?: (uuid_comparison_exp | null),is_organizer?: (Boolean_comparison_exp | null),match_options_id?: (uuid_comparison_exp | null),max_players_per_lineup?: (Int_comparison_exp | null),min_players_per_lineup?: (Int_comparison_exp | null),name?: (String_comparison_exp | null),options?: (match_options_bool_exp | null),organizer_steam_id?: (bigint_comparison_exp | null),organizers?: (tournament_organizers_bool_exp | null),organizers_aggregate?: (tournament_organizers_aggregate_bool_exp | null),results?: (v_team_tournament_results_bool_exp | null),results_aggregate?: (v_team_tournament_results_aggregate_bool_exp | null),rosters?: (tournament_team_roster_bool_exp | null),rosters_aggregate?: (tournament_team_roster_aggregate_bool_exp | null),stages?: (tournament_stages_bool_exp | null),stages_aggregate?: (tournament_stages_aggregate_bool_exp | null),start?: (timestamptz_comparison_exp | null),status?: (e_tournament_status_enum_comparison_exp | null),teams?: (tournament_teams_bool_exp | null),teams_aggregate?: (tournament_teams_aggregate_bool_exp | null)}
41261+
export interface tournaments_bool_exp {_and?: (tournaments_bool_exp[] | null),_not?: (tournaments_bool_exp | null),_or?: (tournaments_bool_exp[] | null),admin?: (players_bool_exp | null),can_cancel?: (Boolean_comparison_exp | null),can_close_registration?: (Boolean_comparison_exp | null),can_join?: (Boolean_comparison_exp | null),can_open_registration?: (Boolean_comparison_exp | null),can_start?: (Boolean_comparison_exp | null),created_at?: (timestamptz_comparison_exp | null),description?: (String_comparison_exp | null),discord_notifications_enabled?: (Boolean_comparison_exp | null),discord_notify_Canceled?: (Boolean_comparison_exp | null),discord_notify_Finished?: (Boolean_comparison_exp | null),discord_notify_Forfeit?: (Boolean_comparison_exp | null),discord_notify_Live?: (Boolean_comparison_exp | null),discord_notify_MapPaused?: (Boolean_comparison_exp | null),discord_notify_PickingPlayers?: (Boolean_comparison_exp | null),discord_notify_Scheduled?: (Boolean_comparison_exp | null),discord_notify_Surrendered?: (Boolean_comparison_exp | null),discord_notify_Tie?: (Boolean_comparison_exp | null),discord_notify_Veto?: (Boolean_comparison_exp | null),discord_notify_WaitingForCheckIn?: (Boolean_comparison_exp | null),discord_notify_WaitingForServer?: (Boolean_comparison_exp | null),discord_role_id?: (String_comparison_exp | null),discord_webhook?: (String_comparison_exp | null),e_tournament_status?: (e_tournament_status_bool_exp | null),has_min_teams?: (Boolean_comparison_exp | null),id?: (uuid_comparison_exp | null),is_organizer?: (Boolean_comparison_exp | null),joined_tournament?: (Boolean_comparison_exp | null),match_options_id?: (uuid_comparison_exp | null),max_players_per_lineup?: (Int_comparison_exp | null),min_players_per_lineup?: (Int_comparison_exp | null),name?: (String_comparison_exp | null),options?: (match_options_bool_exp | null),organizer_steam_id?: (bigint_comparison_exp | null),organizers?: (tournament_organizers_bool_exp | null),organizers_aggregate?: (tournament_organizers_aggregate_bool_exp | null),results?: (v_team_tournament_results_bool_exp | null),results_aggregate?: (v_team_tournament_results_aggregate_bool_exp | null),rosters?: (tournament_team_roster_bool_exp | null),rosters_aggregate?: (tournament_team_roster_aggregate_bool_exp | null),stages?: (tournament_stages_bool_exp | null),stages_aggregate?: (tournament_stages_aggregate_bool_exp | null),start?: (timestamptz_comparison_exp | null),status?: (e_tournament_status_enum_comparison_exp | null),teams?: (tournament_teams_bool_exp | null),teams_aggregate?: (tournament_teams_aggregate_bool_exp | null)}
4125841262

4125941263

4126041264
/** input type for incrementing numeric columns in table "tournaments" */
@@ -41335,7 +41339,7 @@ export interface tournaments_on_conflict {constraint: tournaments_constraint,upd
4133541339

4133641340

4133741341
/** Ordering options when selecting data from "tournaments". */
41338-
export interface tournaments_order_by {admin?: (players_order_by | null),can_cancel?: (order_by | null),can_close_registration?: (order_by | null),can_join?: (order_by | null),can_open_registration?: (order_by | null),can_start?: (order_by | null),created_at?: (order_by | null),description?: (order_by | null),discord_notifications_enabled?: (order_by | null),discord_notify_Canceled?: (order_by | null),discord_notify_Finished?: (order_by | null),discord_notify_Forfeit?: (order_by | null),discord_notify_Live?: (order_by | null),discord_notify_MapPaused?: (order_by | null),discord_notify_PickingPlayers?: (order_by | null),discord_notify_Scheduled?: (order_by | null),discord_notify_Surrendered?: (order_by | null),discord_notify_Tie?: (order_by | null),discord_notify_Veto?: (order_by | null),discord_notify_WaitingForCheckIn?: (order_by | null),discord_notify_WaitingForServer?: (order_by | null),discord_role_id?: (order_by | null),discord_webhook?: (order_by | null),e_tournament_status?: (e_tournament_status_order_by | null),has_min_teams?: (order_by | null),id?: (order_by | null),is_organizer?: (order_by | null),match_options_id?: (order_by | null),max_players_per_lineup?: (order_by | null),min_players_per_lineup?: (order_by | null),name?: (order_by | null),options?: (match_options_order_by | null),organizer_steam_id?: (order_by | null),organizers_aggregate?: (tournament_organizers_aggregate_order_by | null),results_aggregate?: (v_team_tournament_results_aggregate_order_by | null),rosters_aggregate?: (tournament_team_roster_aggregate_order_by | null),stages_aggregate?: (tournament_stages_aggregate_order_by | null),start?: (order_by | null),status?: (order_by | null),teams_aggregate?: (tournament_teams_aggregate_order_by | null)}
41342+
export interface tournaments_order_by {admin?: (players_order_by | null),can_cancel?: (order_by | null),can_close_registration?: (order_by | null),can_join?: (order_by | null),can_open_registration?: (order_by | null),can_start?: (order_by | null),created_at?: (order_by | null),description?: (order_by | null),discord_notifications_enabled?: (order_by | null),discord_notify_Canceled?: (order_by | null),discord_notify_Finished?: (order_by | null),discord_notify_Forfeit?: (order_by | null),discord_notify_Live?: (order_by | null),discord_notify_MapPaused?: (order_by | null),discord_notify_PickingPlayers?: (order_by | null),discord_notify_Scheduled?: (order_by | null),discord_notify_Surrendered?: (order_by | null),discord_notify_Tie?: (order_by | null),discord_notify_Veto?: (order_by | null),discord_notify_WaitingForCheckIn?: (order_by | null),discord_notify_WaitingForServer?: (order_by | null),discord_role_id?: (order_by | null),discord_webhook?: (order_by | null),e_tournament_status?: (e_tournament_status_order_by | null),has_min_teams?: (order_by | null),id?: (order_by | null),is_organizer?: (order_by | null),joined_tournament?: (order_by | null),match_options_id?: (order_by | null),max_players_per_lineup?: (order_by | null),min_players_per_lineup?: (order_by | null),name?: (order_by | null),options?: (match_options_order_by | null),organizer_steam_id?: (order_by | null),organizers_aggregate?: (tournament_organizers_aggregate_order_by | null),results_aggregate?: (v_team_tournament_results_aggregate_order_by | null),rosters_aggregate?: (tournament_team_roster_aggregate_order_by | null),stages_aggregate?: (tournament_stages_aggregate_order_by | null),start?: (order_by | null),status?: (order_by | null),teams_aggregate?: (tournament_teams_aggregate_order_by | null)}
4133941343

4134041344

4134141345
/** primary key columns input for table: tournaments */

generated/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46217,6 +46217,9 @@ export default {
4621746217
"is_organizer": [
4621846218
3
4621946219
],
46220+
"joined_tournament": [
46221+
3
46222+
],
4622046223
"match_options_id": [
4622146224
2498
4622246225
],
@@ -46750,6 +46753,9 @@ export default {
4675046753
"is_organizer": [
4675146754
4
4675246755
],
46756+
"joined_tournament": [
46757+
4
46758+
],
4675346759
"match_options_id": [
4675446760
2499
4675546761
],
@@ -47173,6 +47179,9 @@ export default {
4717347179
"is_organizer": [
4717447180
1476
4717547181
],
47182+
"joined_tournament": [
47183+
1476
47184+
],
4717647185
"match_options_id": [
4717747186
1476
4717847187
],

hasura/functions/tournaments/can_join_tournament.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,22 @@ BEGIN
5050
-- Player can join if they are not on a roster and not a team admin
5151
RETURN NOT is_team_admin;
5252
END;
53+
$$;
54+
55+
CREATE OR REPLACE FUNCTION public.joined_tournament(tournament public.tournaments, hasura_session json) RETURNS boolean
56+
LANGUAGE plpgsql STABLE
57+
AS $$
58+
DECLARE
59+
on_roster boolean;
60+
BEGIN
61+
SELECT EXISTS (
62+
SELECT 1
63+
FROM tournament_team_roster ttr
64+
WHERE
65+
tournament_id = tournament.id
66+
AND player_steam_id = (hasura_session ->> 'x-hasura-user-id')::bigint
67+
) INTO on_roster;
68+
69+
RETURN on_roster;
70+
END;
5371
$$;

hasura/metadata/actions.graphql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ type Mutation {
5454
): SuccessOutput
5555
}
5656

57-
type Mutation {
58-
deleteTournament(
59-
tournament_id: uuid!
60-
): SuccessOutput
61-
}
62-
6357
type Mutation {
6458
deleteServerItem(
6559
node_id: String!
@@ -68,6 +62,12 @@ type Mutation {
6862
): SuccessOutput
6963
}
7064

65+
type Mutation {
66+
deleteTournament(
67+
tournament_id: uuid!
68+
): SuccessOutput
69+
}
70+
7171
type Mutation {
7272
denyInvite(
7373
invite_id: uuid!

hasura/metadata/actions.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,22 @@ actions:
6767
forward_client_headers: true
6868
permissions:
6969
- role: administrator
70-
- name: deleteTournament
70+
- name: deleteServerItem
7171
definition:
7272
kind: synchronous
7373
handler: '{{HASURA_GRAPHQL_ACTIONS_HOOK}}'
7474
forward_client_headers: true
7575
permissions:
76-
- role: user
77-
comment: Delete a tournament and clean up demo files
78-
- name: deleteServerItem
76+
- role: administrator
77+
comment: Delete file or directory on game server
78+
- name: deleteTournament
7979
definition:
8080
kind: synchronous
8181
handler: '{{HASURA_GRAPHQL_ACTIONS_HOOK}}'
8282
forward_client_headers: true
8383
permissions:
84-
- role: administrator
85-
comment: Delete file or directory on game server
84+
- role: user
85+
comment: Delete a tournament and clean up demo files
8686
- name: denyInvite
8787
definition:
8888
kind: synchronous

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ computed_fields:
9191
name: is_tournament_organizer
9292
schema: public
9393
session_argument: hasura_session
94+
- name: joined_tournament
95+
definition:
96+
function:
97+
name: joined_tournament
98+
schema: public
99+
session_argument: hasura_session
94100
- name: max_players_per_lineup
95101
definition:
96102
function:

src/chat/chat.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export class ChatService {
114114
client.user.steam_id,
115115
);
116116

117+
118+
console.log({
119+
tournaments
120+
});
117121
if (tournaments.length === 0) {
118122
return;
119123
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export enum SystemSettingName {
2+
Updates = "updates",
3+
ChatMessageTtl = "chat_message_ttl",
4+
DemoNetworkLimiter = "demo_network_limiter",
5+
PublicDefaultModels = "public.default_models",
6+
SupportsDiscordBot = "public.supports_discord_bot",
7+
SupportsGameServerNodes = "supports_game_server_nodes",
8+
SupportsGameServerVersionPinning = "supports_game_server_version_pinning",
9+
}

0 commit comments

Comments
 (0)