fix(api): correct champion history and deduplicate stats builds
Apply participant and champion filters before pagination and exclude timeline payloads. Route result statistics through the durable outbox, reuse current fragments, and serialize projection effects without spending retries on contention. Validated with 716 API tests, 32 isolated Redis integration tests, API typecheck and build, and lint on changed files.
This commit is contained in:
1 parent
ef141a13d0
commit
f2eec479d9
14 files changed
+704
-47
No files matched your search
@@ -7,7 +7,6 @@ import {
|
||||
import { createHash } from 'node:crypto';
|
||||
import mongoose from 'mongoose';
|
||||
import { CommunityStatsService } from '../community-stats/community-stats.service';
|
||||
import { MatchStatsService } from '../community-stats/match-stats.service';
|
||||
import {
|
||||
CompetitionBootstrapService,
|
||||
type CompetitionBootstrapMatch,
|
||||
@@ -95,7 +94,6 @@ export class TournamentResultService {
|
||||
private readonly riotMatchService: RiotMatchService,
|
||||
private readonly riotJobQueueService: RiotJobQueueService,
|
||||
private readonly communityStatsService: CommunityStatsService,
|
||||
private readonly matchStatsService: MatchStatsService,
|
||||
private readonly distributedLockService: DistributedLockService,
|
||||
private readonly competitionBootstrapService: CompetitionBootstrapService,
|
||||
private readonly competitionCommandService: CompetitionCommandService,
|
||||
@@ -516,9 +514,7 @@ export class TournamentResultService {
|
||||
params.match,
|
||||
competition,
|
||||
);
|
||||
if (!result.replayed) {
|
||||
await this.rebuildMatchStatsSafe(params.match, result.revision);
|
||||
}
|
||||
// acceptGame commits the stats rebuild to the durable Competition outbox.
|
||||
return {
|
||||
kind: 'accepted',
|
||||
displayNumber: mapped.displayNumber,
|
||||
@@ -708,21 +704,6 @@ export class TournamentResultService {
|
||||
}
|
||||
}
|
||||
|
||||
private async rebuildMatchStatsSafe(
|
||||
match: MatchDocument,
|
||||
sourceRevision: number,
|
||||
): Promise<void> {
|
||||
try {
|
||||
await this.matchStatsService.buildAndUpsert(match._id, {
|
||||
sourceRevision,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.warn(
|
||||
`Failed to rebuild match stats for ${match._id.toString()} at Competition revision ${sourceRevision}: ${errorMessage(error)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async ensureRiotMatchPersisted(
|
||||
riotMatchId: string,
|
||||
region: RiotRegionalRoute,
|
||||
|
||||
Reference in new issue
Block a user