Added lanes (first try)
All checks were successful
pipeline / build-and-push-images (push) Successful in 24s
pipeline / deploy (push) Successful in 7s

This commit is contained in:
2024-11-27 20:59:03 +01:00
parent cca1909eb6
commit 43968e4cf1
22 changed files with 173 additions and 24 deletions

View File

@@ -141,6 +141,7 @@ async function championInfos(client, patch: number, champion: Champion) {
let winningMatches = 0;
let losingMatches = 0;
let totalMatches = 0;
const lanes : Array<{data: string, count: number}> = [];
const runes : Array<Rune> = [];
const builds : Builds = {tree:treeInit(), start: [], bootsFirst: 0, boots: [], lateGame: []}
for await (let match of allMatches) {
@@ -156,6 +157,12 @@ async function championInfos(client, patch: number, champion: Champion) {
else
losingMatches += 1;
// Lanes
// TODO: make stats lane-dependant
const already = lanes.find((x) => x.data == participant.teamPosition)
if(already == undefined) lanes.push({count:1, data: participant.teamPosition})
else already.count += 1
// Runes
handleParticipantRunes(participant, runes)
@@ -168,6 +175,9 @@ async function championInfos(client, patch: number, champion: Champion) {
let totalChampionMatches = winningMatches + losingMatches;
lanes.sort((a, b) => b.count - a.count)
arrayRemovePercentage(lanes, totalChampionMatches, 0.15)
// Filter runes to keep 3 most played
runes.sort((a, b) => b.count - a.count)
if(runes.length > 3)
@@ -198,6 +208,7 @@ async function championInfos(client, patch: number, champion: Champion) {
return {name: champion.name,
alias: champion.alias.toLowerCase(),
id: championId,
lanes: lanes,
winrate: winningMatches / totalChampionMatches,
gameCount: totalChampionMatches,
pickrate: totalChampionMatches/totalMatches,
@@ -236,7 +247,6 @@ async function makeChampionsStats(client, patch : number) {
const database = client.db("champions")
const collection = database.collection(patch)
await collection.createIndex({id:1})
await collection.createIndex({alias:1})
}