Skip to content

Commit 291576d

Browse files
committed
fix: improve Discord voice channel reliability and cleanup
- Increase tournament voice cache TTL from 7 to 30 days to prevent channel orphaning for long-running tournaments - Cache brand name query in getArchiveCategoryName for 1 hour to avoid redundant Hasura queries on every call - Remove redundant ready room deletion in removeTournamentVoice since the category children loop already handles it - Remove unreachable SingleElimination branch in getBracketRoundLabel
1 parent 3e0331f commit 291576d

3 files changed

Lines changed: 16 additions & 28 deletions

File tree

src/discord-bot/discord-bot-messaging/discord-bot-messaging.service.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,22 @@ export class DiscordBotMessagingService {
207207
}
208208

209209
private async getArchiveCategoryName() {
210-
const { settings_by_pk } = await this.hasura.query({
211-
settings_by_pk: {
212-
__args: {
213-
name: "public.brand_name",
214-
},
215-
value: true,
210+
const brandName = await this.cache.remember<string>(
211+
"settings:brand_name",
212+
async () => {
213+
const { settings_by_pk } = await this.hasura.query({
214+
settings_by_pk: {
215+
__args: {
216+
name: "public.brand_name",
217+
},
218+
value: true,
219+
},
220+
});
221+
return settings_by_pk?.value || this.config.get<AppConfig>("app").name;
216222
},
217-
});
218-
219-
const name =
220-
settings_by_pk?.value || this.config.get<AppConfig>("app").name;
221-
222-
return `${name} Matches Archive`;
223+
60 * 60,
224+
);
225+
return `${brandName} Matches Archive`;
223226
}
224227

225228
public async removeArchivedThreads() {

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,6 @@ export class DiscordTournamentVoiceService {
360360
try {
361361
const guild = await this.bot.client.guilds.fetch(voiceCache.guildId);
362362

363-
try {
364-
const readyRoom = await guild.channels.fetch(voiceCache.readyRoomId);
365-
if (readyRoom) {
366-
await readyRoom.delete();
367-
}
368-
} catch (error) {
369-
this.logger.warn(
370-
`[${tournamentId}] unable to delete ready room`,
371-
error,
372-
);
373-
}
374-
375363
try {
376364
const category = await guild.channels.fetch(voiceCache.categoryId);
377365
if (category && category.type === ChannelType.GuildCategory) {
@@ -413,7 +401,7 @@ export class DiscordTournamentVoiceService {
413401
await this.cache.put(
414402
this.getVoiceCacheKey(tournamentId),
415403
data,
416-
7 * 24 * 60 * 60,
404+
30 * 24 * 60 * 60,
417405
);
418406
}
419407

src/discord-bot/discord-tournament-voice/utilities/getBracketRoundLabel.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export function getBracketRoundLabel(
3030
}
3131

3232
if (totalMatchesInRound === 2) {
33-
if (isLastRound && stageType === "SingleElimination") {
34-
return "Final";
35-
}
3633
return isDE ? "WB Semi-Finals" : "Semi-Finals";
3734
}
3835

0 commit comments

Comments
 (0)