fix: kda issue in records tab and add season number to all matches

This commit is contained in:
Valentin Kaelin 2020-01-25 12:33:28 +01:00
parent 4a0a76686e
commit dfd0c04fe7
3 changed files with 19 additions and 3 deletions

View file

@ -56,6 +56,7 @@ class EditMatch extends Command {
// All matches from the db
const matches = await Match.all()
const matchesArray = matches.toJSON()
console.log(`${matchesArray.length} matches to edit.`)
// Create jobs
const jobs = []

View file

@ -142,7 +142,6 @@ class MatchRepository {
$match: {
summoner_puuid: puuid,
result: { $not: { $eq: 'Remake' } },
'stats.kda': { $not: { $eq: '∞' } },
gamemode: { $nin: [800, 810, 820, 830, 840, 850] },
}
},
@ -155,7 +154,7 @@ class MatchRepository {
maxGold: { $max: '$stats.gold' },
maxTime: { $max: '$time' },
maxMinions: { $max: '$stats.minions' },
maxKda: { $max: '$stats.kda' },
maxKda: { $max: '$stats.realKda' },
maxDmgTaken: { $max: '$stats.dmgTaken' },
maxDmgChamp: { $max: '$stats.dmgChamp' },
maxDmgObj: { $max: '$stats.dmgObj' },
@ -171,7 +170,7 @@ class MatchRepository {
'gold': '$stats.gold',
'time': '$time',
'minions': '$stats.minions',
'kda': '$stats.kda',
'kda': '$stats.realKda',
'dmgTaken': '$stats.dmgTaken',
'dmgChamp': '$stats.dmgChamp',
'dmgObj': '$stats.dmgObj',

View file

@ -25,6 +25,12 @@ class MatchTransformer {
this.perkstyles = perkstyles.styles
this.summonerSpells = summonerSpells
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
*/
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 {
map: match.mapId,
gamemode: match.queueId,
date: match.gameCreation,
region: match.platformId.toLowerCase(),
season,
time: match.gameDuration
}
}
@ -80,8 +94,10 @@ class MatchTransformer {
if (stats.kills + stats.assists !== 0 && stats.deaths === 0) {
stats.kda = '∞'
stats.realKda = stats.kills + stats.assists
} else {
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