diff --git a/apps/api/src/modules/community-stats/community-stats.service.spec.ts b/apps/api/src/modules/community-stats/community-stats.service.spec.ts index e1fc3f95..d49eacb5 100644 --- a/apps/api/src/modules/community-stats/community-stats.service.spec.ts +++ b/apps/api/src/modules/community-stats/community-stats.service.spec.ts @@ -222,7 +222,9 @@ describe('CommunityStatsService', () => { const setDetail = jest.fn(); const service = new CommunityStatsService( { - getModel: async () => ({ exists: () => ({ exec: async () => null }) }), + getModel: async () => ({ + exists: () => ({ exec: async () => null }), + }), } as unknown as ConnectionService, { get: async () => null, diff --git a/apps/api/src/modules/community-stats/community-stats.service.ts b/apps/api/src/modules/community-stats/community-stats.service.ts index 5bbd6313..6c62fa1d 100644 --- a/apps/api/src/modules/community-stats/community-stats.service.ts +++ b/apps/api/src/modules/community-stats/community-stats.service.ts @@ -649,9 +649,8 @@ export class CommunityStatsService { if (retryAt <= now) this.rawRecoveryRetryAfter.delete(field); } if (this.rawRecoveryRetryAfter.size >= 1000) { - this.rawRecoveryRetryAfter.delete( - this.rawRecoveryRetryAfter.keys().next().value!, - ); + const oldest = this.rawRecoveryRetryAfter.keys().next(); + if (!oldest.done) this.rawRecoveryRetryAfter.delete(oldest.value); } this.rawRecoveryRetryAfter.set( key.field, diff --git a/apps/api/src/modules/global/database/schema.ts b/apps/api/src/modules/global/database/schema.ts index 58fee7a5..83e785ba 100644 --- a/apps/api/src/modules/global/database/schema.ts +++ b/apps/api/src/modules/global/database/schema.ts @@ -40,7 +40,10 @@ export const MATCH_STATUSES: MatchStatus[] = [ 'finished', ]; -export const MATCH_EVENT_TYPES = ['inhouse', 'tournament'] as const satisfies readonly MatchEventType[]; +export const MATCH_EVENT_TYPES = [ + 'inhouse', + 'tournament', +] as const satisfies readonly MatchEventType[]; export type TeamSide = 'blue' | 'red'; export const TEAM_SIDES: TeamSide[] = ['blue', 'red']; @@ -2554,7 +2557,10 @@ MatchStatsSchema.index({ MatchStatsSchema.index({ communityId: 1, userIds: 1 }); MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 }); MatchStatsSchema.index({ communityId: 1, championIds: 1 }); -MatchStatsSchema.index(MATCH_STATS_RIOT_MATCH_INDEX.key, MATCH_STATS_RIOT_MATCH_INDEX.options); +MatchStatsSchema.index( + MATCH_STATS_RIOT_MATCH_INDEX.key, + MATCH_STATS_RIOT_MATCH_INDEX.options, +); export const tournamentModelDefinitions: Array< ModelDefinition & { name: keyof TournamentModelTypes } diff --git a/apps/api/src/modules/match/dto/create-match.dto.spec.ts b/apps/api/src/modules/match/dto/create-match.dto.spec.ts index ed53598d..23fe58e0 100644 --- a/apps/api/src/modules/match/dto/create-match.dto.spec.ts +++ b/apps/api/src/modules/match/dto/create-match.dto.spec.ts @@ -3,7 +3,11 @@ import { BadRequestException, ValidationPipe } from '@nestjs/common'; import { plainToInstance } from 'class-transformer'; import { validateSync } from 'class-validator'; import mongoose from 'mongoose'; -import { CreateMatchDto, JoinMatchDto, UpdateMatchDto } from './create-match.dto'; +import { + CreateMatchDto, + JoinMatchDto, + UpdateMatchDto, +} from './create-match.dto'; describe('CreateMatchDto game mode cutover', () => { it('rejects the removed live bracket mode', () => { @@ -75,7 +79,9 @@ describe('Grand final format validation', () => { doubleEliminationGrandFinalGameCount: 2, }); expect(validateSync(update)).toEqual([ - expect.objectContaining({ property: 'doubleEliminationGrandFinalGameCount' }), + expect.objectContaining({ + property: 'doubleEliminationGrandFinalGameCount', + }), ]); }); }); @@ -93,16 +99,19 @@ describe('Match event type validation', () => { }), ), ).toEqual([]); - expect(validateSync(plainToInstance(UpdateMatchDto, { eventType }))).toEqual( - [], - ); + expect( + validateSync(plainToInstance(UpdateMatchDto, { eventType })), + ).toEqual([]); }, ); - it.each(['double-elimination', null])('rejects %s as an event type', (eventType) => { - const dto = plainToInstance(UpdateMatchDto, { eventType }); - expect(validateSync(dto)).toEqual([ - expect.objectContaining({ property: 'eventType' }), - ]); - }); + it.each(['double-elimination', null])( + 'rejects %s as an event type', + (eventType) => { + const dto = plainToInstance(UpdateMatchDto, { eventType }); + expect(validateSync(dto)).toEqual([ + expect.objectContaining({ property: 'eventType' }), + ]); + }, + ); }); diff --git a/apps/api/src/modules/match/match-public.presenter.ts b/apps/api/src/modules/match/match-public.presenter.ts index df1b80c0..e9106863 100644 --- a/apps/api/src/modules/match/match-public.presenter.ts +++ b/apps/api/src/modules/match/match-public.presenter.ts @@ -26,7 +26,10 @@ interface PublicMatchSource { gameCount: number; gameMode: MatchGameMode; roundRobinMaxRounds?: number; - doubleElimination?: { resetFinalEnabled?: boolean; grandFinalGameCount?: 1 | 3 | 5 }; + doubleElimination?: { + resetFinalEnabled?: boolean; + grandFinalGameCount?: 1 | 3 | 5; + }; hostUserId?: IdLike; participants: Array<{ userId: IdLike; diff --git a/apps/api/src/modules/match/match.controller.spec.ts b/apps/api/src/modules/match/match.controller.spec.ts index 7d763291..811c06e2 100644 --- a/apps/api/src/modules/match/match.controller.spec.ts +++ b/apps/api/src/modules/match/match.controller.spec.ts @@ -69,7 +69,12 @@ describe('MatchController partial updates', () => { const controller = new MatchController(matchService as never); const body = plainToInstance(UpdateMatchDto, { eventType: 'tournament' }); - await controller.updateMatch(user as UserDocument, communityId, matchId, body); + await controller.updateMatch( + user as UserDocument, + communityId, + matchId, + body, + ); expect(matchService.update).toHaveBeenCalledWith({ communityId,