mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +00:00
fix: kda issue in records tab and add season number to all matches
This commit is contained in:
parent
4a0a76686e
commit
dfd0c04fe7
3 changed files with 19 additions and 3 deletions
|
|
@ -56,6 +56,7 @@ class EditMatch extends Command {
|
||||||
// All matches from the db
|
// All matches from the db
|
||||||
const matches = await Match.all()
|
const matches = await Match.all()
|
||||||
const matchesArray = matches.toJSON()
|
const matchesArray = matches.toJSON()
|
||||||
|
console.log(`${matchesArray.length} matches to edit.`)
|
||||||
|
|
||||||
// Create jobs
|
// Create jobs
|
||||||
const jobs = []
|
const jobs = []
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,6 @@ class MatchRepository {
|
||||||
$match: {
|
$match: {
|
||||||
summoner_puuid: puuid,
|
summoner_puuid: puuid,
|
||||||
result: { $not: { $eq: 'Remake' } },
|
result: { $not: { $eq: 'Remake' } },
|
||||||
'stats.kda': { $not: { $eq: '∞' } },
|
|
||||||
gamemode: { $nin: [800, 810, 820, 830, 840, 850] },
|
gamemode: { $nin: [800, 810, 820, 830, 840, 850] },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -155,7 +154,7 @@ class MatchRepository {
|
||||||
maxGold: { $max: '$stats.gold' },
|
maxGold: { $max: '$stats.gold' },
|
||||||
maxTime: { $max: '$time' },
|
maxTime: { $max: '$time' },
|
||||||
maxMinions: { $max: '$stats.minions' },
|
maxMinions: { $max: '$stats.minions' },
|
||||||
maxKda: { $max: '$stats.kda' },
|
maxKda: { $max: '$stats.realKda' },
|
||||||
maxDmgTaken: { $max: '$stats.dmgTaken' },
|
maxDmgTaken: { $max: '$stats.dmgTaken' },
|
||||||
maxDmgChamp: { $max: '$stats.dmgChamp' },
|
maxDmgChamp: { $max: '$stats.dmgChamp' },
|
||||||
maxDmgObj: { $max: '$stats.dmgObj' },
|
maxDmgObj: { $max: '$stats.dmgObj' },
|
||||||
|
|
@ -171,7 +170,7 @@ class MatchRepository {
|
||||||
'gold': '$stats.gold',
|
'gold': '$stats.gold',
|
||||||
'time': '$time',
|
'time': '$time',
|
||||||
'minions': '$stats.minions',
|
'minions': '$stats.minions',
|
||||||
'kda': '$stats.kda',
|
'kda': '$stats.realKda',
|
||||||
'dmgTaken': '$stats.dmgTaken',
|
'dmgTaken': '$stats.dmgTaken',
|
||||||
'dmgChamp': '$stats.dmgChamp',
|
'dmgChamp': '$stats.dmgChamp',
|
||||||
'dmgObj': '$stats.dmgObj',
|
'dmgObj': '$stats.dmgObj',
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ class MatchTransformer {
|
||||||
this.perkstyles = perkstyles.styles
|
this.perkstyles = perkstyles.styles
|
||||||
this.summonerSpells = summonerSpells
|
this.summonerSpells = summonerSpells
|
||||||
this.sortTeamByRole = Helpers.sortTeamByRole
|
this.sortTeamByRole = Helpers.sortTeamByRole
|
||||||
|
|
||||||
|
// League of Legends seasons timestamps
|
||||||
|
this.seasons = {
|
||||||
|
0: 9,
|
||||||
|
1578628800000: 10
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,11 +48,19 @@ class MatchTransformer {
|
||||||
* Get global data about the match
|
* Get global data about the match
|
||||||
*/
|
*/
|
||||||
getGameInfos(match) {
|
getGameInfos(match) {
|
||||||
|
// Get season number
|
||||||
|
const arrSeasons = Object.keys(this.seasons)
|
||||||
|
arrSeasons.push(match.gameCreation)
|
||||||
|
arrSeasons.sort()
|
||||||
|
const indexSeason = arrSeasons.indexOf(match.gameCreation) - 1
|
||||||
|
const season = this.seasons[arrSeasons[indexSeason]]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
map: match.mapId,
|
map: match.mapId,
|
||||||
gamemode: match.queueId,
|
gamemode: match.queueId,
|
||||||
date: match.gameCreation,
|
date: match.gameCreation,
|
||||||
region: match.platformId.toLowerCase(),
|
region: match.platformId.toLowerCase(),
|
||||||
|
season,
|
||||||
time: match.gameDuration
|
time: match.gameDuration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,8 +94,10 @@ class MatchTransformer {
|
||||||
|
|
||||||
if (stats.kills + stats.assists !== 0 && stats.deaths === 0) {
|
if (stats.kills + stats.assists !== 0 && stats.deaths === 0) {
|
||||||
stats.kda = '∞'
|
stats.kda = '∞'
|
||||||
|
stats.realKda = stats.kills + stats.assists
|
||||||
} else {
|
} else {
|
||||||
stats.kda = +(stats.deaths === 0 ? 0 : ((stats.kills + stats.assists) / stats.deaths)).toFixed(2)
|
stats.kda = +(stats.deaths === 0 ? 0 : ((stats.kills + stats.assists) / stats.deaths)).toFixed(2)
|
||||||
|
stats.realKda = stats.kda
|
||||||
}
|
}
|
||||||
|
|
||||||
// Percent stats / Per minute stats : only for detailed match
|
// Percent stats / Per minute stats : only for detailed match
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue