mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +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 { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||||
|
import { getCurrentSeason } from 'App/helpers'
|
||||||
import Summoner from 'App/Models/Summoner'
|
import Summoner from 'App/Models/Summoner'
|
||||||
import Jax from 'App/Services/Jax'
|
import Jax from 'App/Services/Jax'
|
||||||
import MatchService from 'App/Services/MatchService'
|
import MatchService from 'App/Services/MatchService'
|
||||||
|
|
@ -7,6 +8,7 @@ import SummonerBasicValidator from 'App/Validators/SummonerBasicValidator'
|
||||||
|
|
||||||
export default class SummonersController {
|
export default class SummonersController {
|
||||||
public async basic({ request, response }: HttpContextContract) {
|
public async basic({ request, response }: HttpContextContract) {
|
||||||
|
console.time('BASIC_REQUEST')
|
||||||
const { summoner, region } = await request.validate(SummonerBasicValidator)
|
const { summoner, region } = await request.validate(SummonerBasicValidator)
|
||||||
const finalJSON: any = {}
|
const finalJSON: any = {}
|
||||||
|
|
||||||
|
|
@ -28,6 +30,10 @@ export default class SummonersController {
|
||||||
// MATCH LIST
|
// MATCH LIST
|
||||||
finalJSON.matchList = await MatchService.updateMatchList(account, summonerDB)
|
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
|
// CURRENT GAME
|
||||||
const currentGame = await Jax.Spectator.summonerID(account.id, region)
|
const currentGame = await Jax.Spectator.summonerID(account.id, region)
|
||||||
finalJSON.playing = !!currentGame
|
finalJSON.playing = !!currentGame
|
||||||
|
|
@ -37,9 +43,11 @@ export default class SummonersController {
|
||||||
finalJSON.ranked = await SummonerService.getRanked(account, region)
|
finalJSON.ranked = await SummonerService.getRanked(account, region)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
|
console.timeEnd('BASIC_REQUEST')
|
||||||
return response.json(null)
|
return response.json(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.timeEnd('BASIC_REQUEST')
|
||||||
return response.json(finalJSON)
|
return response.json(finalJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue