Skip to content

Commit ca987fc

Browse files
authored
chore: prettier (#130)
1 parent 7b3b9a8 commit ca987fc

File tree

10 files changed

+104
-109
lines changed

10 files changed

+104
-109
lines changed

src/cache/CacheTag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class CacheTag {
1111
this.tag = tags.join(":");
1212
this.forgetTag = `forget:${this.tag}`;
1313
}
14-
14+
1515
async get(key?: string): Promise<CachedValue> {
1616
return await this.waitForLock(async () => {
1717
const values = await this.cacheStore.get(this.tag);

src/cache/cache.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export class CacheService {
100100
}
101101
await new Promise((resolve) => setTimeout(resolve, 100));
102102
}
103-
throw new Error(`Failed to acquire lock for ${key} after ${maxAttempts} attempts`);
103+
throw new Error(
104+
`Failed to acquire lock for ${key} after ${maxAttempts} attempts`,
105+
);
104106
}
105107

106108
private async expireIn(key: string, seconds: number) {

src/discord-bot/discord-tournament-voice/discord-tournament-voice.module.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { CacheModule } from "../../cache/cache.module";
66
import { loggerFactory } from "../../utilities/LoggerFactory";
77

88
@Module({
9-
imports: [
10-
forwardRef(() => DiscordBotModule),
11-
HasuraModule,
12-
CacheModule,
13-
],
9+
imports: [forwardRef(() => DiscordBotModule), HasuraModule, CacheModule],
1410
providers: [DiscordTournamentVoiceService, loggerFactory()],
1511
exports: [DiscordTournamentVoiceService],
1612
})

src/discord-bot/discord-tournament-voice/discord-tournament-voice.service.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { forwardRef, Inject, Injectable, Logger } from "@nestjs/common";
2-
import {
3-
CategoryChannel,
4-
ChannelType,
5-
PermissionsBitField,
6-
} from "discord.js";
2+
import { CategoryChannel, ChannelType, PermissionsBitField } from "discord.js";
73
import { CacheService } from "../../cache/cache.service";
84
import { HasuraService } from "../../hasura/hasura.service";
95
import { DiscordBotService } from "../discord-bot.service";
@@ -43,7 +39,11 @@ export class DiscordTournamentVoiceService {
4339
},
4440
});
4541

46-
if (!tournament || !tournament.discord_voice_enabled || !tournament.discord_guild_id) {
42+
if (
43+
!tournament ||
44+
!tournament.discord_voice_enabled ||
45+
!tournament.discord_guild_id
46+
) {
4747
return;
4848
}
4949

@@ -163,7 +163,10 @@ export class DiscordTournamentVoiceService {
163163

164164
const lineup1 = bracket.match?.lineup_1;
165165

166-
const existingMatchVoice = await this.voiceChannels.getVoiceCache(matchId, lineup1?.id as string);
166+
const existingMatchVoice = await this.voiceChannels.getVoiceCache(
167+
matchId,
168+
lineup1?.id as string,
169+
);
167170
if (existingMatchVoice) {
168171
return; // Already created (e.g., from WaitingForCheckIn trigger)
169172
}
@@ -194,7 +197,8 @@ export class DiscordTournamentVoiceService {
194197
});
195198

196199
const totalMatchesInRound =
197-
(bracketsInSameRound.tournament_brackets_aggregate.aggregate.count as number) || 1;
200+
(bracketsInSameRound.tournament_brackets_aggregate.aggregate
201+
.count as number) || 1;
198202

199203
const maxRound = await this.hasura.query({
200204
tournament_brackets_aggregate: {
@@ -216,7 +220,8 @@ export class DiscordTournamentVoiceService {
216220
});
217221

218222
const highestRound =
219-
(maxRound.tournament_brackets_aggregate.aggregate.max?.round as number) || bracketRound;
223+
(maxRound.tournament_brackets_aggregate.aggregate.max?.round as number) ||
224+
bracketRound;
220225
const isLastRound = bracketRound === highestRound;
221226
const isLoserBracket = bracketPath === "loser";
222227

@@ -311,9 +316,7 @@ export class DiscordTournamentVoiceService {
311316
const playerName = lineupPlayer.player?.name as string | undefined;
312317

313318
if (!discordId) {
314-
unlinkedPlayers.push(
315-
playerName || (lineupPlayer.steam_id as string),
316-
);
319+
unlinkedPlayers.push(playerName || (lineupPlayer.steam_id as string));
317320
continue;
318321
}
319322

@@ -363,23 +366,19 @@ export class DiscordTournamentVoiceService {
363366
try {
364367
const category = await guild.channels.fetch(voiceCache.categoryId);
365368
if (category && category.type === ChannelType.GuildCategory) {
366-
for (const [, child] of (category as CategoryChannel).children.cache) {
369+
for (const [, child] of (category as CategoryChannel).children
370+
.cache) {
367371
await child.delete().catch(() => {});
368372
}
369373
await category.delete();
370374
}
371375
} catch (error) {
372-
this.logger.warn(
373-
`[${tournamentId}] unable to delete category`,
374-
error,
375-
);
376+
this.logger.warn(`[${tournamentId}] unable to delete category`, error);
376377
}
377378

378379
await this.cache.forget(this.getVoiceCacheKey(tournamentId));
379380

380-
this.logger.log(
381-
`[${tournamentId}] removed tournament voice channels`,
382-
);
381+
this.logger.log(`[${tournamentId}] removed tournament voice channels`);
383382
} catch (error) {
384383
this.logger.error(
385384
`[${tournamentId}] failed to remove tournament voice channels`,

src/game-server-node/game-server-node.controller.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,20 @@ export class GameServerNodeController {
122122
if (rootDisk) {
123123
const diskUsedPercent = parseInt(rootDisk.usedPercent);
124124
if (Number.isNaN(diskUsedPercent)) {
125-
this.logger.warn(`Invalid disk usedPercent from node ${payload.node}: "${rootDisk.usedPercent}"`);
125+
this.logger.warn(
126+
`Invalid disk usedPercent from node ${payload.node}: "${rootDisk.usedPercent}"`,
127+
);
126128
return;
127129
}
128130
const now = Date.now();
129131
const cooldownKey = (level: string) => `${payload.node}:${level}`;
130132

131133
const shouldNotify = (level: string) => {
132134
const last = this.diskWarningCooldowns.get(cooldownKey(level));
133-
return !last || now - last > GameServerNodeController.DISK_WARNING_COOLDOWN_MS;
135+
return (
136+
!last ||
137+
now - last > GameServerNodeController.DISK_WARNING_COOLDOWN_MS
138+
);
134139
};
135140

136141
const settings = await this.cache.remember<
@@ -344,8 +349,7 @@ export class GameServerNodeController {
344349
return;
345350
}
346351

347-
const errorMessage =
348-
request.body?.error || "Unknown provisioning error";
352+
const errorMessage = request.body?.error || "Unknown provisioning error";
349353

350354
await this.notifications.send(
351355
"GameNodeStatus",
@@ -393,8 +397,7 @@ export class GameServerNodeController {
393397

394398
const freshDiskGb =
395399
parseInt(
396-
settings.find((s) => s.name === "reserved_disk_space_fresh_gb")
397-
?.value,
400+
settings.find((s) => s.name === "reserved_disk_space_fresh_gb")?.value,
398401
) || 120;
399402
const existingDiskGb =
400403
parseInt(

src/game-server-node/game-server-node.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,14 @@ export class GameServerNodeService {
240240
cpu_governor_info: cpuGovernorInfo,
241241
cpu_frequency_info: cpuFrequencyInfo,
242242
disk_available_gb: rootDisk
243-
? (Number.isNaN(parseInt(rootDisk.available)) ? null : Math.round(parseInt(rootDisk.available) / (1024 * 1024)))
243+
? Number.isNaN(parseInt(rootDisk.available))
244+
? null
245+
: Math.round(parseInt(rootDisk.available) / (1024 * 1024))
244246
: null,
245247
disk_used_percent: rootDisk
246-
? (Number.isNaN(parseInt(rootDisk.usedPercent)) ? null : parseInt(rootDisk.usedPercent))
248+
? Number.isNaN(parseInt(rootDisk.usedPercent))
249+
? null
250+
: parseInt(rootDisk.usedPercent)
247251
: null,
248252
...(game_server_nodes_by_pk.token ? { token: null } : {}),
249253
},

src/rcon/rcon.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,4 @@ export class RconService {
393393
const lockKey = `cvars:lock:${buildId}`;
394394
await this.redisManager.getConnection().del(lockKey);
395395
}
396-
397396
}

src/sockets/sockets.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,4 @@ export class SocketsService {
226226
}),
227227
);
228228
}
229-
230229
}

src/system/system.service.ts

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -64,82 +64,82 @@ export class SystemService {
6464
try {
6565
const tailscaleConfig = this.config.get<TailscaleConfig>("tailscale");
6666

67-
let supportsGameServerNodes = false;
68-
if (
69-
tailscaleConfig.key &&
70-
tailscaleConfig.secret &&
71-
tailscaleConfig.netName
72-
) {
73-
supportsGameServerNodes = true;
74-
}
67+
let supportsGameServerNodes = false;
68+
if (
69+
tailscaleConfig.key &&
70+
tailscaleConfig.secret &&
71+
tailscaleConfig.netName
72+
) {
73+
supportsGameServerNodes = true;
74+
}
7575

76-
await this.hasura.mutation({
77-
insert_settings_one: {
78-
__args: {
79-
object: {
80-
name: SystemSettingName.SupportsGameServerNodes,
81-
value: supportsGameServerNodes.toString(),
82-
},
83-
on_conflict: {
84-
constraint: "settings_pkey",
85-
update_columns: ["value"],
86-
},
76+
await this.hasura.mutation({
77+
insert_settings_one: {
78+
__args: {
79+
object: {
80+
name: SystemSettingName.SupportsGameServerNodes,
81+
value: supportsGameServerNodes.toString(),
82+
},
83+
on_conflict: {
84+
constraint: "settings_pkey",
85+
update_columns: ["value"],
8786
},
88-
__typename: true,
8987
},
90-
});
88+
__typename: true,
89+
},
90+
});
9191

92-
const discordConfig = this.config.get<DiscordConfig>("discord");
92+
const discordConfig = this.config.get<DiscordConfig>("discord");
9393

94-
let supportsDiscordBot = false;
95-
if (
96-
discordConfig.clientId &&
97-
discordConfig.clientSecret &&
98-
discordConfig.token
99-
) {
100-
supportsDiscordBot = true;
101-
}
94+
let supportsDiscordBot = false;
95+
if (
96+
discordConfig.clientId &&
97+
discordConfig.clientSecret &&
98+
discordConfig.token
99+
) {
100+
supportsDiscordBot = true;
101+
}
102102

103-
await this.hasura.mutation({
104-
insert_settings_one: {
105-
__args: {
106-
object: {
107-
name: SystemSettingName.SupportsDiscordBot,
108-
value: supportsDiscordBot.toString(),
109-
},
110-
on_conflict: {
111-
constraint: "settings_pkey",
112-
update_columns: ["value"],
113-
},
103+
await this.hasura.mutation({
104+
insert_settings_one: {
105+
__args: {
106+
object: {
107+
name: SystemSettingName.SupportsDiscordBot,
108+
value: supportsDiscordBot.toString(),
109+
},
110+
on_conflict: {
111+
constraint: "settings_pkey",
112+
update_columns: ["value"],
114113
},
115-
__typename: true,
116114
},
117-
});
115+
__typename: true,
116+
},
117+
});
118118

119-
const steamConfig = this.config.get<SteamConfig>("steam");
119+
const steamConfig = this.config.get<SteamConfig>("steam");
120120

121-
let supportsGameServerNodeVersionPinning = false;
122-
if (steamConfig.steamUser && steamConfig.steamPassword) {
123-
supportsGameServerNodeVersionPinning = true;
124-
}
121+
let supportsGameServerNodeVersionPinning = false;
122+
if (steamConfig.steamUser && steamConfig.steamPassword) {
123+
supportsGameServerNodeVersionPinning = true;
124+
}
125125

126-
await this.hasura.mutation({
127-
insert_settings_one: {
128-
__args: {
129-
object: {
130-
name: SystemSettingName.SupportsGameServerVersionPinning,
131-
value: supportsGameServerNodeVersionPinning.toString(),
132-
},
133-
on_conflict: {
134-
constraint: "settings_pkey",
135-
update_columns: ["value"],
136-
},
126+
await this.hasura.mutation({
127+
insert_settings_one: {
128+
__args: {
129+
object: {
130+
name: SystemSettingName.SupportsGameServerVersionPinning,
131+
value: supportsGameServerNodeVersionPinning.toString(),
132+
},
133+
on_conflict: {
134+
constraint: "settings_pkey",
135+
update_columns: ["value"],
137136
},
138-
__typename: true,
139137
},
140-
});
138+
__typename: true,
139+
},
140+
});
141141

142-
this.featuresDetected = true;
142+
this.featuresDetected = true;
143143
} catch (error) {
144144
this.logger.warn("Error detecting features", error);
145145
setTimeout(() => {

src/tournaments/tournaments.controller.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,15 @@ export class TournamentsController {
1717
) {}
1818

1919
@HasuraEvent()
20-
public async tournament_events(
21-
data: HasuraEventData<tournaments_set_input>,
22-
) {
20+
public async tournament_events(data: HasuraEventData<tournaments_set_input>) {
2321
const tournamentId = (data.new.id || data.old.id) as string;
2422
const status = data.new.status as string;
2523

26-
if (
27-
status === "Live" &&
28-
data.old.status !== "Live"
29-
) {
24+
if (status === "Live" && data.old.status !== "Live") {
3025
await this.tournamentVoice.createTournamentReadyRoom(tournamentId);
3126
}
3227

33-
if (
34-
["Finished", "Cancelled", "CancelledMinTeams"].includes(status)
35-
) {
28+
if (["Finished", "Cancelled", "CancelledMinTeams"].includes(status)) {
3629
await this.tournamentVoice.removeTournamentVoice(tournamentId);
3730
}
3831
}

0 commit comments

Comments
 (0)