mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
fix: spectator v5 + new gamename
This commit is contained in:
parent
346273ef2d
commit
ed9dd523ba
7 changed files with 32 additions and 20 deletions
|
|
@ -191,7 +191,7 @@ export const actions = {
|
||||||
const resp = await axios({
|
const resp = await axios({
|
||||||
url: 'summoner/live',
|
url: 'summoner/live',
|
||||||
data: {
|
data: {
|
||||||
id: state.basic.account.id,
|
puuid: state.basic.account.puuid,
|
||||||
region: rootState.regionsList[rootState.settings.region],
|
region: rootState.regionsList[rootState.settings.region],
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export default class SummonersController {
|
||||||
SummonerService.getAllSummonerNames(account, summonerDB),
|
SummonerService.getAllSummonerNames(account, summonerDB),
|
||||||
this.getSeasons(account.puuid),
|
this.getSeasons(account.puuid),
|
||||||
MatchRepository.gamemodes(account.puuid),
|
MatchRepository.gamemodes(account.puuid),
|
||||||
Jax.Spectator.summonerID(account.id, region),
|
Jax.Spectator.puuid(account.puuid, region),
|
||||||
SummonerService.getRanked(account.id, region),
|
SummonerService.getRanked(account.id, region),
|
||||||
MatchRepository.recentActivity(account.puuid),
|
MatchRepository.recentActivity(account.puuid),
|
||||||
// Only last 100 matchIds in matchlist
|
// Only last 100 matchIds in matchlist
|
||||||
|
|
@ -146,10 +146,10 @@ export default class SummonersController {
|
||||||
*/
|
*/
|
||||||
public async liveMatchDetails({ request, response }: HttpContextContract) {
|
public async liveMatchDetails({ request, response }: HttpContextContract) {
|
||||||
console.time('liveMatchDetails')
|
console.time('liveMatchDetails')
|
||||||
const { id, region } = await request.validate(SummonerLiveValidator)
|
const { puuid, region } = await request.validate(SummonerLiveValidator)
|
||||||
|
|
||||||
// CURRENT GAME
|
// CURRENT GAME
|
||||||
const currentGame = await Jax.Spectator.summonerID(id, region)
|
const currentGame = await Jax.Spectator.puuid(puuid, region)
|
||||||
|
|
||||||
if (!currentGame) {
|
if (!currentGame) {
|
||||||
return response.json(null)
|
return response.json(null)
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ export default class SpectatorEndpoint {
|
||||||
this.limiter = limiter
|
this.limiter = limiter
|
||||||
}
|
}
|
||||||
|
|
||||||
public summonerID(summonerID: string, region: string): Promise<CurrentGameInfoDTO | undefined> {
|
public puuid(puuid: string, region: string): Promise<CurrentGameInfoDTO | undefined> {
|
||||||
return new JaxRequest(
|
return new JaxRequest(
|
||||||
region,
|
region,
|
||||||
this.config,
|
this.config,
|
||||||
`spectator/v4/active-games/by-summoner/${summonerID}`,
|
`spectator/v5/active-games/by-summoner/${puuid}`,
|
||||||
this.limiter,
|
this.limiter,
|
||||||
0
|
0
|
||||||
).execute()
|
).execute()
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,15 @@ export interface SummonerDTO {
|
||||||
accountId: string
|
accountId: string
|
||||||
profileIconId: number
|
profileIconId: number
|
||||||
revisionDate: number
|
revisionDate: number
|
||||||
name: string
|
|
||||||
id: string
|
id: string
|
||||||
puuid: string
|
puuid: string
|
||||||
summonerLevel: number
|
summonerLevel: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SummonerDTOExtended extends SummonerDTO {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
export default class SummonerEndpoint {
|
export default class SummonerEndpoint {
|
||||||
private config: JaxConfig
|
private config: JaxConfig
|
||||||
private limiter: RiotRateLimiter
|
private limiter: RiotRateLimiter
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ export default class JaxRequest {
|
||||||
// Don't log 404 when summoner isn't playing or the summoner doesn't exist
|
// Don't log 404 when summoner isn't playing or the summoner doesn't exist
|
||||||
// Or if summoner has no MatchList
|
// Or if summoner has no MatchList
|
||||||
if (
|
if (
|
||||||
!this.endpoint.includes('spectator/v4/active-games/by-summoner') &&
|
!this.endpoint.includes('spectator/v5/active-games/by-summoner') &&
|
||||||
!this.endpoint.includes('summoner/v4/summoners/by-name') &&
|
!this.endpoint.includes('summoner/v4/summoners/by-name') &&
|
||||||
!this.endpoint.includes('match/v4/matchlists/by-account')
|
!this.endpoint.includes('match/v4/matchlists/by-account')
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import Jax from './Jax'
|
import Jax from './Jax'
|
||||||
import { SummonerDTO } from 'App/Services/Jax/src/Endpoints/SummonerEndpoint'
|
import { SummonerDTO, SummonerDTOExtended } from 'App/Services/Jax/src/Endpoints/SummonerEndpoint'
|
||||||
import { LeagueEntryDTO } from './Jax/src/Endpoints/LeagueEndpoint'
|
import { LeagueEntryDTO } from './Jax/src/Endpoints/LeagueEndpoint'
|
||||||
import Summoner from 'App/Models/Summoner'
|
import Summoner from 'App/Models/Summoner'
|
||||||
import { PlayerRankParsed } from 'App/Parsers/ParsedType'
|
import { PlayerRankParsed } from 'App/Parsers/ParsedType'
|
||||||
|
|
@ -33,7 +33,7 @@ class SummonerService {
|
||||||
* Helper to transform League Data from the Riot API
|
* Helper to transform League Data from the Riot API
|
||||||
* @param league raw data of the league from Riot API
|
* @param league raw data of the league from Riot API
|
||||||
*/
|
*/
|
||||||
private getleagueData(league?: LeagueEntryDTO): LeagueEntryByQueue | null {
|
private getLeagueData(league?: LeagueEntryDTO): LeagueEntryByQueue | null {
|
||||||
if (!league) {
|
if (!league) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
@ -54,22 +54,31 @@ class SummonerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get summnoner account infos for a searched summoner name
|
* Get summoner account infos for a searched summoner name
|
||||||
* @param summonerName
|
* @param summonerName
|
||||||
* @param region
|
* @param region
|
||||||
*/
|
*/
|
||||||
public async getSummoner(summonerName: string, region: string): Promise<SummonerDTO | null> {
|
public async getSummoner(
|
||||||
const name = summonerName.toLowerCase()
|
summonerName: string,
|
||||||
|
region: string
|
||||||
|
): Promise<SummonerDTOExtended | null> {
|
||||||
|
let name = summonerName.toLowerCase()
|
||||||
|
|
||||||
// Get old way: summonerName
|
// Get old way
|
||||||
if (!name.includes(ACCOUNT_NAME_DELIMITER)) {
|
if (!name.includes(ACCOUNT_NAME_DELIMITER)) {
|
||||||
return Jax.Summoner.summonerName(name, region)
|
name = `${name}-${region}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get new way: gameName#tagLine
|
// Get new way: gameName#tagLine
|
||||||
const [gameName, tagLine] = name.split(ACCOUNT_NAME_DELIMITER)
|
const [gameName, tagLine] = name.split(ACCOUNT_NAME_DELIMITER)
|
||||||
const account = await Jax.Account.byRiotId(gameName, tagLine, region)
|
const account = await Jax.Account.byRiotId(gameName, tagLine, region)
|
||||||
return account ? Jax.Summoner.summonerPuuid(account.puuid, region) : null
|
|
||||||
|
if (account) {
|
||||||
|
const summoner = await Jax.Summoner.summonerPuuid(account.puuid, region)
|
||||||
|
return { ...summoner, name: account.gameName }
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +86,7 @@ class SummonerService {
|
||||||
* @param account of the summoner
|
* @param account of the summoner
|
||||||
* @param summonerDB summoner in the database
|
* @param summonerDB summoner in the database
|
||||||
*/
|
*/
|
||||||
public async getAllSummonerNames(account: SummonerDTO, summonerDB: Summoner) {
|
public async getAllSummonerNames(account: SummonerDTOExtended, summonerDB: Summoner) {
|
||||||
await summonerDB.related('names').firstOrCreate({
|
await summonerDB.related('names').firstOrCreate({
|
||||||
name: account.name,
|
name: account.name,
|
||||||
})
|
})
|
||||||
|
|
@ -95,9 +104,9 @@ class SummonerService {
|
||||||
|
|
||||||
if (ranked && ranked.length) {
|
if (ranked && ranked.length) {
|
||||||
result.soloQ =
|
result.soloQ =
|
||||||
this.getleagueData(ranked.find((e) => e.queueType === 'RANKED_SOLO_5x5')) || undefined
|
this.getLeagueData(ranked.find((e) => e.queueType === 'RANKED_SOLO_5x5')) || undefined
|
||||||
result.flex5v5 =
|
result.flex5v5 =
|
||||||
this.getleagueData(ranked.find((e) => e.queueType === 'RANKED_FLEX_SR')) || undefined
|
this.getLeagueData(ranked.find((e) => e.queueType === 'RANKED_FLEX_SR')) || undefined
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export default class SummonerLiveValidator {
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
public schema = schema.create({
|
public schema = schema.create({
|
||||||
id: schema.string(),
|
puuid: schema.string(),
|
||||||
region: schema.string(),
|
region: schema.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue