Add timeline vector metrics
This commit is contained in:
1 parent
77ba93b94a
commit
a69e86f2bc
13 files changed
+1543
-37
No files matched your search
@@ -22,6 +22,7 @@ import type {
|
||||
import { FeatureExtractorService } from './feature-extractor.service';
|
||||
import { ProfileBuilderService } from './profile-builder.service';
|
||||
import { TimelineDerivedService } from './timeline-derived.service';
|
||||
import { TimelineMetricService } from './timeline-metric.service';
|
||||
|
||||
interface MatchRecord {
|
||||
matchId: string;
|
||||
@@ -48,6 +49,14 @@ function isRecordValue(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function isTimelinePayload(value: unknown): value is Record<string, unknown> {
|
||||
if (!isRecordValue(value)) {
|
||||
return false;
|
||||
}
|
||||
const info = asRecord(value.info);
|
||||
return Array.isArray(info.frames) && info.frames.length > 0;
|
||||
}
|
||||
|
||||
function asNumber(value: unknown, fallback = 0): number {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
||||
}
|
||||
@@ -75,6 +84,7 @@ export class AnalysisPipelineService {
|
||||
private readonly featureExtractorService: FeatureExtractorService,
|
||||
private readonly profileBuilderService: ProfileBuilderService,
|
||||
private readonly timelineDerivedService: TimelineDerivedService,
|
||||
private readonly timelineMetricService: TimelineMetricService,
|
||||
) {}
|
||||
|
||||
public async processUserAnalysisJob(
|
||||
@@ -311,7 +321,7 @@ export class AnalysisPipelineService {
|
||||
existingTimeline: unknown,
|
||||
regionalRoute: UserAnalysisJobData['regionalRoute'],
|
||||
): Promise<Record<string, unknown> | undefined> {
|
||||
if (isRecordValue(existingTimeline)) {
|
||||
if (isTimelinePayload(existingTimeline)) {
|
||||
return existingTimeline;
|
||||
}
|
||||
|
||||
@@ -320,6 +330,12 @@ export class AnalysisPipelineService {
|
||||
matchId,
|
||||
regionalRoute,
|
||||
);
|
||||
if (!isTimelinePayload(timeline)) {
|
||||
this.logger.warn(
|
||||
`Skipping malformed timeline for matchId="${this.safeLogText(matchId)}"`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
await this.storeRiotMatchTimeline(matchId, timeline);
|
||||
return timeline;
|
||||
} catch (error) {
|
||||
@@ -366,12 +382,29 @@ export class AnalysisPipelineService {
|
||||
);
|
||||
if (feature.queueId !== queueId) continue;
|
||||
if (matchRecord.timeline) {
|
||||
feature.derived = {
|
||||
...this.timelineDerivedService.buildDerivedData(
|
||||
matchRecord.timeline,
|
||||
const derived = this.timelineDerivedService.buildDerivedData(
|
||||
matchRecord.timeline,
|
||||
matchRecord.raw,
|
||||
);
|
||||
const timelineMetrics =
|
||||
this.timelineMetricService.extractTimelineMetrics(
|
||||
feature,
|
||||
matchRecord.raw,
|
||||
),
|
||||
matchRecord.timeline,
|
||||
derived,
|
||||
);
|
||||
feature.derived = {
|
||||
...derived,
|
||||
};
|
||||
feature.features = {
|
||||
...feature.features,
|
||||
...timelineMetrics.features,
|
||||
};
|
||||
feature.normalized = {
|
||||
...feature.normalized,
|
||||
...timelineMetrics.normalized,
|
||||
};
|
||||
feature.vector = timelineMetrics.vector;
|
||||
feature.timelineProcessed = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user