mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 04:47:27 +00:00
feat: summoner/basic endpoint should be kinda good now
This commit is contained in:
parent
9a3bb6311c
commit
f04f9e95dd
1 changed files with 8 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import { getCurrentSeason } from 'App/helpers'
|
||||
import Summoner from 'App/Models/Summoner'
|
||||
import Jax from 'App/Services/Jax'
|
||||
import MatchService from 'App/Services/MatchService'
|
||||
|
|
@ -7,6 +8,7 @@ import SummonerBasicValidator from 'App/Validators/SummonerBasicValidator'
|
|||
|
||||
export default class SummonersController {
|
||||
public async basic({ request, response }: HttpContextContract) {
|
||||
console.time('BASIC_REQUEST')
|
||||
const { summoner, region } = await request.validate(SummonerBasicValidator)
|
||||
const finalJSON: any = {}
|
||||
|
||||
|
|
@ -28,6 +30,10 @@ export default class SummonersController {
|
|||
// MATCH LIST
|
||||
finalJSON.matchList = await MatchService.updateMatchList(account, summonerDB)
|
||||
|
||||
// All seasons the summoner has played
|
||||
// TODO: check if there is a way to do that with V5...
|
||||
finalJSON.seasons = [getCurrentSeason()]
|
||||
|
||||
// CURRENT GAME
|
||||
const currentGame = await Jax.Spectator.summonerID(account.id, region)
|
||||
finalJSON.playing = !!currentGame
|
||||
|
|
@ -37,9 +43,11 @@ export default class SummonersController {
|
|||
finalJSON.ranked = await SummonerService.getRanked(account, region)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.timeEnd('BASIC_REQUEST')
|
||||
return response.json(null)
|
||||
}
|
||||
|
||||
console.timeEnd('BASIC_REQUEST')
|
||||
return response.json(finalJSON)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue