refactor: use getSeasonNumber helper in MatchTransformer

This commit is contained in:
Valentin Kaelin 2020-06-21 21:16:13 +02:00
parent c16974fcfb
commit 46d2903340

View file

@ -2,7 +2,7 @@
const Jax = use('App/Services/Jax') const Jax = use('App/Services/Jax')
const RoleIdentificationService = use('App/Services/RoleIdentificationService') const RoleIdentificationService = use('App/Services/RoleIdentificationService')
const { queuesWithRole, sortTeamByRole } = use('App/helpers') const { getSeasonNumber, queuesWithRole, sortTeamByRole } = use('App/helpers')
/** /**
* MatchTransformer class * MatchTransformer class
@ -28,12 +28,6 @@ class MatchTransformer {
this.summonerSpells = summonerSpells this.summonerSpells = summonerSpells
this.championRoles = championRoles this.championRoles = championRoles
this.sortTeamByRole = sortTeamByRole this.sortTeamByRole = sortTeamByRole
// League of Legends seasons timestamps
this.seasons = {
0: 9,
1578628800000: 10
}
} }
/** /**
@ -51,19 +45,12 @@ 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, season: getSeasonNumber(match.gameCreation),
time: match.gameDuration time: match.gameDuration
} }
} }