Add timeline insight metrics
This commit is contained in:
1 parent
a69e86f2bc
commit
1a7a1cca68
5 files changed
+1328
-5
No files matched your search
@@ -222,6 +222,178 @@ function createTimeline() {
|
||||
};
|
||||
}
|
||||
|
||||
function createInsightTimeline() {
|
||||
return {
|
||||
info: {
|
||||
frames: [
|
||||
{
|
||||
timestamp: 10 * 60_000,
|
||||
events: [
|
||||
{
|
||||
actualStartTime: 640_000,
|
||||
type: 'OBJECTIVE_BOUNTY_PRESTART',
|
||||
timestamp: 590_000,
|
||||
teamId: 100,
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({
|
||||
minionsKilled: 80,
|
||||
position: { x: 7_500, y: 7_500 },
|
||||
totalGold: 4_000,
|
||||
xp: 5_000,
|
||||
}),
|
||||
'6': participantFrame({
|
||||
minionsKilled: 72,
|
||||
totalGold: 3_400,
|
||||
xp: 4_700,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 11 * 60_000,
|
||||
events: [
|
||||
{
|
||||
type: 'CHAMPION_KILL',
|
||||
timestamp: 650_000,
|
||||
killerId: 1,
|
||||
victimId: 6,
|
||||
shutdownBounty: 450,
|
||||
assistingParticipantIds: [],
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({ position: { x: 7_800, y: 9_000 } }),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 12 * 60_000,
|
||||
events: [
|
||||
{
|
||||
type: 'TURRET_PLATE_DESTROYED',
|
||||
timestamp: 700_000,
|
||||
teamId: 200,
|
||||
laneType: 'MID_LANE',
|
||||
},
|
||||
{
|
||||
type: 'OBJECTIVE_BOUNTY_FINISH',
|
||||
timestamp: 700_000,
|
||||
teamId: 100,
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({ position: { x: 7_800, y: 7_800 } }),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 800_000,
|
||||
events: [
|
||||
{
|
||||
type: 'CHAMPION_KILL',
|
||||
timestamp: 800_000,
|
||||
killerId: 1,
|
||||
victimId: 7,
|
||||
assistingParticipantIds: [],
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({ position: { x: 9_866, y: 4_414 } }),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 14 * 60_000,
|
||||
events: [],
|
||||
participantFrames: {
|
||||
'1': participantFrame({
|
||||
position: { x: 9_866, y: 4_414 },
|
||||
totalGold: 5_800,
|
||||
}),
|
||||
'2': participantFrame({ position: { x: 8_800, y: 4_600 } }),
|
||||
'3': participantFrame({ position: { x: 1_000, y: 13_000 } }),
|
||||
'6': participantFrame({ totalGold: 5_500 }),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 15 * 60_000,
|
||||
events: [
|
||||
{
|
||||
type: 'ELITE_MONSTER_KILL',
|
||||
timestamp: 900_000,
|
||||
killerId: 2,
|
||||
killerTeamId: 100,
|
||||
monsterType: 'DRAGON',
|
||||
assistingParticipantIds: [1],
|
||||
position: { x: 9_866, y: 4_414 },
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({ position: { x: 9_866, y: 4_414 } }),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 20 * 60_000,
|
||||
events: [
|
||||
{
|
||||
type: 'CHAMPION_KILL',
|
||||
timestamp: 1_030_000,
|
||||
killerId: 6,
|
||||
victimId: 1,
|
||||
assistingParticipantIds: [],
|
||||
},
|
||||
{
|
||||
type: 'CHAMPION_KILL',
|
||||
timestamp: 1_215_000,
|
||||
killerId: 2,
|
||||
victimId: 7,
|
||||
assistingParticipantIds: [],
|
||||
},
|
||||
],
|
||||
participantFrames: {
|
||||
'1': participantFrame({
|
||||
position: { x: 7_500, y: 7_500 },
|
||||
totalGold: 8_000,
|
||||
}),
|
||||
'6': participantFrame({ totalGold: 7_700 }),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function createDeficitRecoveryTimeline() {
|
||||
return {
|
||||
info: {
|
||||
frames: [
|
||||
{
|
||||
timestamp: 10 * 60_000,
|
||||
events: [],
|
||||
participantFrames: {
|
||||
'1': participantFrame({
|
||||
minionsKilled: 65,
|
||||
totalGold: 3_200,
|
||||
xp: 4_200,
|
||||
}),
|
||||
'6': participantFrame({
|
||||
minionsKilled: 75,
|
||||
totalGold: 3_900,
|
||||
xp: 4_600,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamp: 20 * 60_000,
|
||||
events: [],
|
||||
participantFrames: {
|
||||
'1': participantFrame({ totalGold: 7_500 }),
|
||||
'6': participantFrame({ totalGold: 7_300 }),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('TimelineMetricService', () => {
|
||||
const service = new TimelineMetricService();
|
||||
|
||||
@@ -339,4 +511,208 @@ describe('TimelineMetricService', () => {
|
||||
result.normalized.ccTimePerMinute,
|
||||
);
|
||||
});
|
||||
|
||||
it('extracts timeline insight metrics outside the vector', () => {
|
||||
const feature = createBaseFeature();
|
||||
const result = service.extractTimelineMetrics(
|
||||
feature,
|
||||
createRawMatch(),
|
||||
createInsightTimeline(),
|
||||
{
|
||||
advantageEvents: [
|
||||
{
|
||||
timestampMs: 600_000,
|
||||
teamId: 100,
|
||||
type: 'championKill',
|
||||
score: 1,
|
||||
participantIds: [1],
|
||||
},
|
||||
{
|
||||
timestampMs: 650_000,
|
||||
teamId: 100,
|
||||
type: 'championKill',
|
||||
score: 1,
|
||||
participantIds: [1],
|
||||
},
|
||||
{
|
||||
timestampMs: 1_030_000,
|
||||
teamId: 200,
|
||||
type: 'championKill',
|
||||
score: 1,
|
||||
participantIds: [6],
|
||||
},
|
||||
{
|
||||
timestampMs: 1_215_000,
|
||||
teamId: 100,
|
||||
type: 'championKill',
|
||||
score: 1,
|
||||
participantIds: [2],
|
||||
},
|
||||
],
|
||||
deathEvents: [
|
||||
{
|
||||
t: 1_000_000,
|
||||
victimParticipantId: 1,
|
||||
x: 7_500,
|
||||
y: 7_500,
|
||||
zone: 'middleLane',
|
||||
shutdownBountyGiven: 0,
|
||||
nearestAllyDistanceApprox: 5_000,
|
||||
},
|
||||
{
|
||||
t: 1_200_000,
|
||||
victimParticipantId: 1,
|
||||
x: 7_500,
|
||||
y: 7_500,
|
||||
zone: 'middleLane',
|
||||
shutdownBountyGiven: 0,
|
||||
nearestAllyDistanceApprox: 1_000,
|
||||
},
|
||||
],
|
||||
fightClusters: [
|
||||
{
|
||||
startTimeMs: 850_000,
|
||||
endTimeMs: 870_000,
|
||||
killCount: 2,
|
||||
participantIds: [1, 2, 6, 7],
|
||||
openerParticipantIds: [1],
|
||||
cleanupParticipantIds: [2],
|
||||
isTeamfight: false,
|
||||
},
|
||||
],
|
||||
objectiveWindows: [
|
||||
{
|
||||
objectiveTimeMs: 900_000,
|
||||
startTimeMs: 780_000,
|
||||
endTimeMs: 930_000,
|
||||
killerParticipantId: 2,
|
||||
killerTeamId: 100,
|
||||
monsterType: 'DRAGON',
|
||||
position: { x: 9_866, y: 4_414 },
|
||||
},
|
||||
],
|
||||
roamFrames: [
|
||||
{
|
||||
t: 600_000,
|
||||
participantId: 1,
|
||||
teamId: 100,
|
||||
x: 7_500,
|
||||
y: 7_500,
|
||||
zone: 'river',
|
||||
assignedLaneZone: 'middleLane',
|
||||
},
|
||||
{
|
||||
t: 660_000,
|
||||
participantId: 1,
|
||||
teamId: 100,
|
||||
x: 8_000,
|
||||
y: 7_000,
|
||||
zone: 'river',
|
||||
assignedLaneZone: 'middleLane',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.features).toMatchObject({
|
||||
objectiveFightOpeningParticipationRateNumerator: 1,
|
||||
objectiveFightOpeningParticipationRateDenominator: 1,
|
||||
objectiveFightOpeningConvertedToObjectiveRateNumerator: 1,
|
||||
objectiveFightOpeningConvertedToObjectiveRateDenominator: 1,
|
||||
preObjectivePitPresenceRateNumerator: 1,
|
||||
preObjectivePitPresenceRateDenominator: 1,
|
||||
preObjectivePickParticipationRateNumerator: 1,
|
||||
preObjectivePickParticipationRateDenominator: 1,
|
||||
deathFollowedByTeamLossRateNumerator: 1,
|
||||
deathFollowedByTeamLossRateDenominator: 2,
|
||||
deathTradedForTeamAdvantageRateNumerator: 1,
|
||||
deathTradedForTeamAdvantageRateDenominator: 2,
|
||||
deathWhileIsolatedFromNearestAllyRateNumerator: 1,
|
||||
deathWhileIsolatedFromNearestAllyRateDenominator: 2,
|
||||
laneLeadConversionRateNumerator: 1,
|
||||
laneLeadConversionRateDenominator: 1,
|
||||
roamConvertedToTeamAdvantageRateNumerator: 1,
|
||||
roamConvertedToTeamAdvantageRateDenominator: 1,
|
||||
shutdownGoldCollectedPerGame: 450,
|
||||
platePresenceParticipationRateNumerator: 1,
|
||||
platePresenceParticipationRateDenominator: 1,
|
||||
objectiveBountyComebackParticipationRateNumerator: 1,
|
||||
objectiveBountyComebackParticipationRateDenominator: 1,
|
||||
});
|
||||
expect(result.normalized.objectiveFightOpeningParticipationRate).toBe(1);
|
||||
expect(result.normalized.deathFollowedByTeamLossRate).toBe(0.5);
|
||||
expect(result.normalized.deathTradedForTeamAdvantageRate).toBe(0.5);
|
||||
expect(result.normalized.deathWhileIsolatedFromNearestAllyRate).toBe(0.5);
|
||||
expect(result.vector).toHaveLength(VECTOR_METRICS.length);
|
||||
expect(
|
||||
VECTOR_METRICS.some(
|
||||
(metric) => metric.id === 'shutdownGoldCollectedPerGame',
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('extracts early deficit recovery as a sparse ratio metric', () => {
|
||||
const feature = createBaseFeature();
|
||||
const result = service.extractTimelineMetrics(
|
||||
feature,
|
||||
createRawMatch(),
|
||||
createDeficitRecoveryTimeline(),
|
||||
{
|
||||
advantageEvents: [],
|
||||
deathEvents: [],
|
||||
fightClusters: [],
|
||||
objectiveWindows: [],
|
||||
roamFrames: [],
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.features).toMatchObject({
|
||||
goldDiffAt10: -700,
|
||||
earlyDeficitRecoveryRateNumerator: 1,
|
||||
earlyDeficitRecoveryRateDenominator: 1,
|
||||
laneLeadConversionRateNumerator: 0,
|
||||
laneLeadConversionRateDenominator: 0,
|
||||
});
|
||||
expect(result.normalized.earlyDeficitRecoveryRate).toBe(1);
|
||||
});
|
||||
|
||||
it('does not count the death kill event as a follow-up team loss', () => {
|
||||
const feature = createBaseFeature();
|
||||
const result = service.extractTimelineMetrics(
|
||||
feature,
|
||||
createRawMatch(),
|
||||
createTimeline(),
|
||||
{
|
||||
advantageEvents: [
|
||||
{
|
||||
timestampMs: 400_000,
|
||||
teamId: 200,
|
||||
type: 'championKill',
|
||||
score: 1,
|
||||
participantIds: [6],
|
||||
},
|
||||
],
|
||||
deathEvents: [
|
||||
{
|
||||
t: 400_000,
|
||||
victimParticipantId: 1,
|
||||
x: 4_000,
|
||||
y: 4_000,
|
||||
zone: 'middleLane',
|
||||
shutdownBountyGiven: 0,
|
||||
nearestAllyDistanceApprox: 1_500,
|
||||
},
|
||||
],
|
||||
fightClusters: [],
|
||||
objectiveWindows: [],
|
||||
roamFrames: [],
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.features).toMatchObject({
|
||||
deathFollowedByTeamLossRateNumerator: 0,
|
||||
deathFollowedByTeamLossRateDenominator: 1,
|
||||
});
|
||||
expect(result.normalized.deathFollowedByTeamLossRate).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user