feat: tag items depending on region and gold state when bought
All checks were successful
pipeline / lint-and-format (push) Successful in 4m29s
pipeline / build-and-push-images (push) Successful in 1m28s

This commit is contained in:
2026-04-18 21:08:58 +02:00
parent 17024f91a8
commit a5728a147f
7 changed files with 231 additions and 10 deletions

View File

@@ -2,12 +2,14 @@ import { MongoClient } from 'mongodb'
import {
ItemTree,
GoldAdvantageTag,
PlatformCounts,
treeInit,
treeMerge,
treeCutBranches,
treeSort,
treeMergeTree,
areTreeSimilars
areTreeSimilars,
treeDeriveTags
} from './item_tree'
import { Match, Timeline, Participant, Frame } from './api'
@@ -101,6 +103,8 @@ type LaneData = {
builds: Builds
matchups?: Array<MatchupData>
summonerSpells: Array<{ id: number; count: number; pickrate?: number }>
// Region distribution for this lane (used for tag derivation)
regionDistribution?: PlatformCounts
}
type ChampionData = {
champion: Champion
@@ -332,11 +336,21 @@ function handleMatch(match: Match, champions: Map<number, ChampionData>, platfor
winrate: 0,
pickrate: 0,
summonerSpells: [],
matchups: []
matchups: [],
regionDistribution: { euw: 0, eun: 0, na: 0, kr: 0 }
}
champion.lanes.push(lane)
} else lane.count += 1
// Track region distribution for this lane
if (lane.regionDistribution && platform) {
const platformKey = platform.toLowerCase()
if (platformKey === 'euw1') lane.regionDistribution.euw++
else if (platformKey === 'eun1') lane.regionDistribution.eun++
else if (platformKey === 'na1') lane.regionDistribution.na++
else if (platformKey === 'kr') lane.regionDistribution.kr++
}
// Initialize matchups if not present
if (!lane.matchups) {
lane.matchups = []
@@ -589,6 +603,9 @@ function cleanupLaneBuilds(lane: LaneData) {
treeCutBranches(build.items, 4, 0.05)
treeSort(build.items)
// Derive tags from purchase patterns (gold advantage, region)
treeDeriveTags(build.items, lane.regionDistribution)
// Remove boots that are not within percentage threshold
arrayRemovePercentage(build.boots, build.count, 0.05)
build.boots.sort((a, b) => b.count - a.count)