Allow collecting data from EUNE, NA, KR on top of EUW
All checks were successful
pipeline / lint-and-format (push) Successful in 4m44s
pipeline / build-and-push-images (push) Successful in 4m7s

- match_collector: query API and build collections for each platform
- match_collector: aggregate champion stats of each platform in one collection with platform annotations
- frontend: replace stats to count matches in platform-specific collections
- frontend: replace "EUW Challengers" with all supported platforms
- dev: adapted scripts to count match in platforms
This commit is contained in:
2026-04-17 16:25:19 +02:00
parent 0f84b9a707
commit dae65c8fa2
7 changed files with 342 additions and 104 deletions

View File

@@ -1,5 +1,12 @@
type GoldAdvantageTag = 'ahead' | 'behind' | 'even'
type PlatformCounts = {
euw: number
eun: number
na: number
kr: number
}
type ItemTree = {
data: number | undefined
count: number
@@ -12,6 +19,13 @@ type ItemTree = {
evenCount: number
meanGold: number
}
// Platform tracking
platformCount: PlatformCounts
}
function initPlatformCounts(): PlatformCounts {
return { euw: 0, eun: 0, na: 0, kr: 0 }
}
function treeInit(): ItemTree {
@@ -19,16 +33,8 @@ function treeInit(): ItemTree {
data: undefined,
count: 0,
children: [],
boughtWhen: { aheadCount: 0, behindCount: 0, evenCount: 0, meanGold: 0 }
}
}
function treeNode(data: number, count: number): ItemTree {
return {
data: data,
count: count,
children: [],
boughtWhen: { aheadCount: 0, behindCount: 0, evenCount: 0, meanGold: 0 }
boughtWhen: { aheadCount: 0, behindCount: 0, evenCount: 0, meanGold: 0 },
platformCount: initPlatformCounts()
}
}
@@ -49,6 +55,12 @@ function nodeMerge(itemtree: ItemTree, node: ItemTree) {
child.boughtWhen.evenCount += node.boughtWhen.evenCount
child.boughtWhen.behindCount += node.boughtWhen.behindCount
// Merge platform counts
child.platformCount.euw += node.platformCount.euw
child.platformCount.eun += node.platformCount.eun
child.platformCount.na += node.platformCount.na
child.platformCount.kr += node.platformCount.kr
next = child
break
}
@@ -56,7 +68,13 @@ function nodeMerge(itemtree: ItemTree, node: ItemTree) {
// If not found, add item node at this level
if (next == null && item !== undefined) {
next = treeNode(item, count)
next = {
data: item,
count: count,
children: [],
boughtWhen: { ...node.boughtWhen },
platformCount: { ...node.platformCount }
}
itemtree.children.push(next)
}
@@ -68,11 +86,12 @@ function nodeMerge(itemtree: ItemTree, node: ItemTree) {
*/
function treeMerge(
itemtree: ItemTree,
items: Array<{ itemId: number; goldAdvantage: GoldAdvantageTag }>
items: Array<{ itemId: number; goldAdvantage: GoldAdvantageTag; platform?: string }>
) {
let current = itemtree
for (const item of items) {
const platformKey = item.platform ? item.platform.toLowerCase() : null
current = nodeMerge(current, {
data: item.itemId,
count: 1,
@@ -82,7 +101,13 @@ function treeMerge(
behindCount: item.goldAdvantage == 'behind' ? 1 : 0,
meanGold: 0
},
children: []
children: [],
platformCount: {
euw: platformKey === 'euw1' ? 1 : 0,
eun: platformKey === 'eun1' ? 1 : 0,
na: platformKey === 'na1' ? 1 : 0,
kr: platformKey === 'kr' ? 1 : 0
}
})
}
}
@@ -96,7 +121,8 @@ function treeCutBranches(itemtree: ItemTree, thresholdCount: number, thresholdPe
data: undefined,
count: +Infinity,
children: [],
boughtWhen: { aheadCount: 0, behindCount: 0, evenCount: 0, meanGold: 0 }
boughtWhen: { aheadCount: 0, behindCount: 0, evenCount: 0, meanGold: 0 },
platformCount: initPlatformCounts()
}
)
itemtree.children.splice(itemtree.children.indexOf(leastUsedBranch), 1)
@@ -137,6 +163,12 @@ function treeClone(tree: ItemTree): ItemTree {
behindCount: tree.boughtWhen.behindCount,
evenCount: tree.boughtWhen.evenCount,
meanGold: tree.boughtWhen.meanGold
},
platformCount: {
euw: tree.platformCount.euw,
eun: tree.platformCount.eun,
na: tree.platformCount.na,
kr: tree.platformCount.kr
}
}
}
@@ -148,6 +180,17 @@ function treeMergeTree(t1: ItemTree, t2: ItemTree): ItemTree {
// Merge counts for the root
t1.count += t2.count
// Merge platform counts
t1.platformCount.euw += t2.platformCount.euw
t1.platformCount.eun += t2.platformCount.eun
t1.platformCount.na += t2.platformCount.na
t1.platformCount.kr += t2.platformCount.kr
// Merge boughtWhen
t1.boughtWhen.aheadCount += t2.boughtWhen.aheadCount
t1.boughtWhen.evenCount += t2.boughtWhen.evenCount
t1.boughtWhen.behindCount += t2.boughtWhen.behindCount
// Merge children from t2 into t1
for (const child2 of t2.children) {
// Find matching child in t1 (same data value)
@@ -225,6 +268,7 @@ function areTreeSimilars(t1: ItemTree, t2: ItemTree): number {
export {
ItemTree,
PlatformCounts,
GoldAdvantageTag,
treeMerge,
treeInit,