mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
refactor: get players' ranks with their summonerId instead of names
This commit is contained in:
parent
e7c878deea
commit
e3b5aec70c
3 changed files with 13 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ export default class MatchesController {
|
|||
* @param region of the match
|
||||
*/
|
||||
private async getPlayerRank (summoner: ParticipantDetails, region: string) {
|
||||
const account = await SummonerService.getAccount(summoner.name, region)
|
||||
const account = await Jax.Summoner.summonerId(summoner.summonerId, region)
|
||||
if (account) {
|
||||
const ranked = await SummonerService.getRanked(account, region)
|
||||
summoner.rank = ranked.soloQ ? (({ tier, shortName }) => ({ tier, shortName }))(ranked.soloQ) : null
|
||||
|
|
|
|||
|
|
@ -23,6 +23,16 @@ export default class SummonerEndpoint {
|
|||
this.limiter = limiter
|
||||
}
|
||||
|
||||
public summonerId (summonerId: string, region: string): Promise<SummonerDTO> {
|
||||
return new JaxRequest(
|
||||
region,
|
||||
this.config,
|
||||
`summoner/v4/summoners/${summonerId}`,
|
||||
this.limiter,
|
||||
36000
|
||||
).execute()
|
||||
}
|
||||
|
||||
public summonerName (summonerName: string, region: string): Promise<SummonerDTO> {
|
||||
return new JaxRequest(
|
||||
region,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { queuesWithRole } from 'App/helpers'
|
||||
import Jax from 'App/Services/Jax'
|
||||
import { CurrentGameInfo, CurrentGameParticipant } from 'App/Services/Jax/src/Endpoints/SpectatorEndpoint'
|
||||
import { FinalRoleComposition } from 'App/Services/RoleIdentiticationService'
|
||||
import SummonerService, { LeagueEntriesByQueue } from 'App/Services/SummonerService'
|
||||
|
|
@ -11,7 +12,7 @@ class LiveMatchTransformer extends MatchTransformer {
|
|||
* @param region
|
||||
*/
|
||||
private async getPlayerRank (participant: CurrentGameParticipant, region: string) {
|
||||
const account = await SummonerService.getAccount(participant.summonerName, region)
|
||||
const account = await Jax.Summoner.summonerId(participant.summonerId, region)
|
||||
let ranked: LeagueEntriesByQueue
|
||||
if (account) {
|
||||
ranked = await SummonerService.getRanked(account, region)
|
||||
|
|
|
|||
Loading…
Reference in a new issue