Store timeline derived data

This commit is contained in:
dahyeon committed 2026-07-02 23:13:27 -07:00
1 parent 897e2092a3
commit 1e2f1695ce
3 files changed
+92 -9

No files matched your search

@@ -21,10 +21,12 @@ import type {
} from './analysis.types';
import { FeatureExtractorService } from './feature-extractor.service';
import { ProfileBuilderService } from './profile-builder.service';
import { TimelineDerivedService } from './timeline-derived.service';
interface MatchRecord {
matchId: string;
raw: Record<string, unknown>;
timeline?: Record<string, unknown>;
}
interface ParsedMatchSummary {
@@ -72,6 +74,7 @@ export class AnalysisPipelineService {
private readonly riotApiClient: RiotApiClient,
private readonly featureExtractorService: FeatureExtractorService,
private readonly profileBuilderService: ProfileBuilderService,
private readonly timelineDerivedService: TimelineDerivedService,
) {}
public async processUserAnalysisJob(
@@ -229,12 +232,16 @@ export class AnalysisPipelineService {
if (existingMatch) {
if (this.isEligibleMatch(existingMatch.raw, data.queueId)) {
await this.fetchAndStoreMissingTimeline(
const timeline = await this.fetchAndStoreMissingTimeline(
matchId,
existingMatch.timeline,
data.regionalRoute,
);
matchRecords.push({ matchId, raw: existingMatch.raw });
matchRecords.push({
matchId,
raw: existingMatch.raw,
...(timeline ? { timeline } : {}),
});
}
} else {
const rawMatch = await this.riotApiClient.getMatch(
@@ -243,12 +250,16 @@ export class AnalysisPipelineService {
);
await this.storeRiotMatch(matchId, rawMatch);
if (this.isEligibleMatch(rawMatch, data.queueId)) {
await this.fetchAndStoreMissingTimeline(
const timeline = await this.fetchAndStoreMissingTimeline(
matchId,
undefined,
data.regionalRoute,
);
matchRecords.push({ matchId, raw: rawMatch });
matchRecords.push({
matchId,
raw: rawMatch,
...(timeline ? { timeline } : {}),
});
}
}
} catch (error) {
@@ -299,9 +310,9 @@ export class AnalysisPipelineService {
matchId: string,
existingTimeline: unknown,
regionalRoute: UserAnalysisJobData['regionalRoute'],
): Promise<void> {
): Promise<Record<string, unknown> | undefined> {
if (isRecordValue(existingTimeline)) {
return;
return existingTimeline;
}
try {
@@ -310,10 +321,12 @@ export class AnalysisPipelineService {
regionalRoute,
);
await this.storeRiotMatchTimeline(matchId, timeline);
return timeline;
} catch (error) {
this.logger.warn(
`Skipping timeline fetch for matchId="${this.safeLogText(matchId)}": ${this.safeLogText(errorMessage(error))}`,
);
return undefined;
}
}
@@ -352,6 +365,14 @@ export class AnalysisPipelineService {
puuid,
);
if (feature.queueId !== queueId) continue;
if (matchRecord.timeline) {
feature.derived = {
...this.timelineDerivedService.buildDerivedData(
matchRecord.timeline,
),
};
feature.timelineProcessed = true;
}
await playerMatchFeatureModel
.updateOne(