mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 04:47:27 +00:00
feat: helper to get currentSeason
This commit is contained in:
parent
5cd0837815
commit
c24b4fd161
2 changed files with 10 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import { getCurrentSeason } from 'App/helpers'
|
||||
import Summoner from 'App/Models/Summoner'
|
||||
import MatchRepository from 'App/Repositories/MatchRepository'
|
||||
import Jax from 'App/Services/Jax'
|
||||
|
|
@ -19,7 +20,7 @@ export default class SummonersController {
|
|||
*/
|
||||
private async getSeasons (puuid: string): Promise<number[]> {
|
||||
const seasons = await MatchRepository.seasons(puuid)
|
||||
return seasons.length ? seasons.map(s => s._id) : [10]
|
||||
return seasons.length ? seasons.map(s => s._id) : [getCurrentSeason()]
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,6 +89,14 @@ export function getSeasonNumber (timestamp: number): number {
|
|||
return seasons[arrSeasons[indexSeason]]
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current League of Legends season number
|
||||
*/
|
||||
export function getCurrentSeason () : number {
|
||||
const lastTimestamp = Object.keys(seasons).pop()!
|
||||
return seasons[lastTimestamp]
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort array of Players by roles according to a specific order
|
||||
* @param a first player
|
||||
|
|
|
|||
Loading…
Reference in a new issue