feat: preserve normalized accepted game facts

This commit is contained in:
dahyeon committed 2026-07-12 19:32:19 +00:00
1 parent e6e434d13f
commit f3286e7fd1
4 files changed
+92 -32

No files matched your search

@@ -169,6 +169,19 @@ export interface MigrationGameAcceptedFact extends MigrationFactBase {
seriesId: string;
gameSlotId: string;
ordinal: number;
startedAt: string;
durationSeconds: number;
participants: Array<{
userId: string;
teamId: string;
side: 'blue' | 'red';
summonerName: string;
tagLine: string;
championId: number;
kills: number;
deaths: number;
assists: number;
}>;
evidence:
| { type: 'riot'; riotMatchId: string; payloadHash: string }
| { type: 'legacy'; legacyReference: string };
@@ -908,6 +921,39 @@ function addGameFacts(
seriesId: planned.series.id,
gameSlotId: slot.id,
ordinal: planned.ordinal,
startedAt: occurredAt,
durationSeconds:
typeof game.gameDuration === 'number' ? game.gameDuration : 0,
participants: (game.participants ?? []).flatMap((participant) => {
const userId = opaqueString(participant.userId);
const teamId = teamIds.get(participant.teamIndex ?? -1);
if (
!userId ||
!teamId ||
(participant.side !== 'blue' && participant.side !== 'red')
) {
return [];
}
return [
{
userId,
teamId,
side: participant.side,
summonerName:
typeof participant.summonerName === 'string'
? participant.summonerName
: '',
tagLine:
typeof participant.tagLine === 'string'
? participant.tagLine
: '',
championId: numericValue(participant.championId),
kills: numericValue(participant.kills),
deaths: numericValue(participant.deaths),
assists: numericValue(participant.assists),
},
];
}),
evidence,
mapping: {
mappingVersion: 1,
@@ -1434,6 +1480,10 @@ function positiveInteger(value: unknown): number | undefined {
: undefined;
}
function numericValue(value: unknown): number {
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
}
function issue(
code: string,
message: string,