Using champions alias instead of id in urls
All checks were successful
pipeline / build-and-push-images (push) Successful in 25s
All checks were successful
pipeline / build-and-push-images (push) Successful in 25s
This commit is contained in:
@@ -29,8 +29,14 @@ type Builds = {
|
||||
boots: Array<{data: number, count: number}>
|
||||
lateGame: Array<{data: number, count: number}>
|
||||
}
|
||||
type Champion = {
|
||||
id: Number
|
||||
name: String
|
||||
alias: String
|
||||
}
|
||||
|
||||
async function championInfos(client, patch: number, championId: number) {
|
||||
async function championInfos(client, patch: number, champion: Champion) {
|
||||
const championId = champion.id
|
||||
const database = client.db("matches");
|
||||
const matches = database.collection(patch)
|
||||
const allMatches = matches.find()
|
||||
@@ -181,7 +187,9 @@ async function championInfos(client, patch: number, championId: number) {
|
||||
builds.bootsFirst /= (winningMatches + losingMatches)
|
||||
builds.lateGame.sort((a, b) => b.count - a.count)
|
||||
|
||||
return {id: championId,
|
||||
return {name: champion.name,
|
||||
alias: champion.alias.toLowerCase(),
|
||||
id: championId,
|
||||
winrate:winningMatches / (winningMatches + losingMatches),
|
||||
gameCount:(winningMatches + losingMatches),
|
||||
pickrate:(winningMatches + losingMatches)/totalMatches,
|
||||
@@ -190,8 +198,8 @@ async function championInfos(client, patch: number, championId: number) {
|
||||
};
|
||||
}
|
||||
|
||||
async function makeChampionStat(client, patch, championId) {
|
||||
const championInfo = await championInfos(client, patch, championId)
|
||||
async function makeChampionStat(client, patch : number, champion : Champion) {
|
||||
const championInfo = await championInfos(client, patch, champion)
|
||||
const database = client.db("champions")
|
||||
const collection = database.collection(patch)
|
||||
await collection.updateOne({id: championInfo.id}, {$set: championInfo}, { upsert: true })
|
||||
@@ -203,7 +211,7 @@ async function championList() {
|
||||
return list.slice(1)
|
||||
}
|
||||
|
||||
async function makeChampionsStats(client, patch) {
|
||||
async function makeChampionsStats(client, patch : number) {
|
||||
var globalItems = await itemList()
|
||||
for(let item of globalItems) {
|
||||
itemDict.set(item.id, item)
|
||||
@@ -214,13 +222,14 @@ async function makeChampionsStats(client, patch) {
|
||||
let i = 0;
|
||||
for(let champion of list) {
|
||||
console.log("Entry " + i + "/" + list.length + " (" + champion.name + ")...")
|
||||
await makeChampionStat(client, patch, champion.id)
|
||||
await makeChampionStat(client, patch, champion)
|
||||
i += 1
|
||||
}
|
||||
|
||||
const database = client.db("champions")
|
||||
const collection = database.collection(patch)
|
||||
await collection.createIndex({id:1})
|
||||
await collection.createIndex({alias:1})
|
||||
}
|
||||
|
||||
export default {makeChampionsStats}
|
||||
|
||||
Reference in New Issue
Block a user