feat: connect tournament views to APIs and recover archived stats
Remove development previews and complete hall of fame, match history, official results, and multi-kill API integration. Fix active match pagination and team-ready controls, preserve basic scoreboards, and recover statistics when Riot archives arrive. Use bounded in-process cache invalidation retries and add the Riot match lookup index migration with regression coverage.
This commit is contained in:
1 parent
20e1e6ec04
commit
0d7617e2d2
70 files changed
+3739
-1793
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import type {
|
||||
HallOfFameResponse,
|
||||
MatchDetailResponse,
|
||||
MatchEventType,
|
||||
MatchListResponse,
|
||||
MatchListView,
|
||||
} from '@lolympus/contracts';
|
||||
import {
|
||||
BadRequestException,
|
||||
@@ -17,6 +19,7 @@ import {
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { isISO8601 } from 'class-validator';
|
||||
import mongoose from 'mongoose';
|
||||
import { AllowPublicAccess } from '../auth/allow-public-access.decorator';
|
||||
import { CurrentUser } from '../auth/current-user.decorator';
|
||||
@@ -89,10 +92,38 @@ export class MatchController {
|
||||
@Query('sort') sort?: 'asc' | 'desc',
|
||||
@Query('includeResults') includeResults?: string,
|
||||
@Query('eventType') eventType?: MatchEventType,
|
||||
@Query('view') view?: MatchListView,
|
||||
@Query('asOf') asOf?: string,
|
||||
): Promise<MatchListResponse> {
|
||||
if (eventType !== undefined && !MATCH_EVENT_TYPES.includes(eventType)) {
|
||||
throw new BadRequestException('Invalid eventType.');
|
||||
}
|
||||
if (
|
||||
view !== undefined &&
|
||||
view !== 'active' &&
|
||||
view !== 'upcoming' &&
|
||||
view !== 'history'
|
||||
) {
|
||||
throw new BadRequestException('Invalid view.');
|
||||
}
|
||||
if (
|
||||
view &&
|
||||
(status !== undefined ||
|
||||
scheduledFrom !== undefined ||
|
||||
scheduledTo !== undefined)
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
'view cannot be combined with status or schedule filters.',
|
||||
);
|
||||
}
|
||||
const asOfDate = this.toOptionalDate(asOf);
|
||||
if (
|
||||
asOf !== undefined &&
|
||||
(typeof asOf !== 'string' ||
|
||||
!isISO8601(asOf, { strict: true, strictSeparator: true }) ||
|
||||
!asOfDate)
|
||||
)
|
||||
throw new BadRequestException('Invalid asOf.');
|
||||
const result = await this.matchService.listPage({
|
||||
communityId,
|
||||
status,
|
||||
@@ -103,11 +134,15 @@ export class MatchController {
|
||||
scheduledFrom: this.toOptionalDate(scheduledFrom),
|
||||
scheduledTo: this.toOptionalDate(scheduledTo),
|
||||
sort,
|
||||
...(view ? { view, asOf: asOfDate } : {}),
|
||||
});
|
||||
const historyResults =
|
||||
includeResults === 'true'
|
||||
? await this.matchService.getHistoryResults(communityId, result.matches)
|
||||
: undefined;
|
||||
const eventProgress = view
|
||||
? await this.matchService.getEventProgress(result.matches)
|
||||
: undefined;
|
||||
return {
|
||||
...result,
|
||||
matches: result.matches.map((match) => {
|
||||
@@ -121,11 +156,26 @@ export class MatchController {
|
||||
: {}),
|
||||
});
|
||||
const historyResult = historyResults?.get(summary._id);
|
||||
return historyResult ? { ...summary, historyResult } : summary;
|
||||
return {
|
||||
...summary,
|
||||
...(historyResult ? { historyResult } : {}),
|
||||
...(eventProgress
|
||||
? { eventProgress: eventProgress.get(summary._id) }
|
||||
: {}),
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@Get('hall-of-fame')
|
||||
@AllowPublicAccess()
|
||||
public getHallOfFame(
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
): Promise<HallOfFameResponse> {
|
||||
return this.matchService.getHallOfFame(communityId);
|
||||
}
|
||||
|
||||
@Get(':matchId')
|
||||
@AllowPublicAccess()
|
||||
public async getMatch(
|
||||
@@ -135,7 +185,7 @@ export class MatchController {
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
): Promise<MatchDetailResponse> {
|
||||
const match = await this.matchService.getById(matchId, communityId);
|
||||
return this.matchService.serialize(match, {
|
||||
const summary = this.matchService.serialize(match, {
|
||||
joined: Boolean(
|
||||
currentUser &&
|
||||
match.participants.some((participant) =>
|
||||
@@ -143,6 +193,8 @@ export class MatchController {
|
||||
),
|
||||
),
|
||||
});
|
||||
const progress = await this.matchService.getEventProgress([match]);
|
||||
return { ...summary, eventProgress: progress.get(summary._id) };
|
||||
}
|
||||
|
||||
@Patch(':matchId')
|
||||
@@ -258,6 +310,23 @@ export class MatchController {
|
||||
}
|
||||
|
||||
// 관리자 전용 — 참가자 강제 제외.
|
||||
@Delete(':matchId/participants')
|
||||
@Roles('admin', 'owner', 'member')
|
||||
@UseGuards(RolesGuard)
|
||||
public async cancelJoin(
|
||||
@CurrentUser() currentUser: UserDocument,
|
||||
@Param('communityId', ParseObjectIdPipe)
|
||||
communityId: mongoose.Types.ObjectId,
|
||||
@Param('matchId', ParseObjectIdPipe) matchId: mongoose.Types.ObjectId,
|
||||
): Promise<MatchDetailResponse> {
|
||||
this.assertSameCommunity(currentUser, communityId);
|
||||
const match = await this.matchService.cancelJoin({
|
||||
matchId,
|
||||
userId: currentUser._id,
|
||||
});
|
||||
return this.matchService.serialize(match, { joined: false });
|
||||
}
|
||||
|
||||
@Delete(':matchId/participants/:userId')
|
||||
@Roles('admin', 'owner')
|
||||
@UseGuards(RolesGuard)
|
||||
|
||||
Reference in new issue
Block a user