mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat(champions): add filter by gamemode back
This commit is contained in:
parent
80534a5ca3
commit
5c79f04563
5 changed files with 25 additions and 7 deletions
|
|
@ -36,12 +36,12 @@ export default {
|
|||
|
||||
created() {
|
||||
// Show all queues when loading the page
|
||||
this.queue = -1
|
||||
this.queue = 0
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
// Reload all champions stats for next user visit of the champions tab
|
||||
if (this.queue !== -1)
|
||||
if (this.queue !== 0)
|
||||
this.championsNotLoaded()
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export const state = {
|
|||
ranked: {},
|
||||
recentActivity: [],
|
||||
seasons: [],
|
||||
gamemodes: [],
|
||||
status: '',
|
||||
},
|
||||
overview: {
|
||||
|
|
@ -93,6 +94,7 @@ export const mutations = {
|
|||
state.basic.ranked = infos.ranked
|
||||
state.basic.recentActivity = infos.recentActivity
|
||||
state.basic.seasons = infos.seasons.sort((a, b) => b - a)
|
||||
state.basic.gamemodes = infos.gamemodes
|
||||
state.basic.status = 'found'
|
||||
state.live.match = infos.current
|
||||
state.live.playing = infos.playing
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export default {
|
|||
const queues = Object.keys(gameModes)
|
||||
.filter(gameMode =>
|
||||
gameModes[gameMode].type !== 'Bot' &&
|
||||
this.matchList.find(match => match.queue === Number(gameMode))
|
||||
this.gamemodes.includes(Number(gameMode))
|
||||
)
|
||||
.reduce((obj, key) => {
|
||||
return {
|
||||
|
|
@ -52,13 +52,13 @@ export default {
|
|||
[key]: gameModes[key]
|
||||
}
|
||||
}, {})
|
||||
return { '-1': { type: 'Normal', name: 'All queues' }, ...queues }
|
||||
return { '0': { type: 'Normal', name: 'All queues' }, ...queues }
|
||||
},
|
||||
...mapGetters('summoner', ['summonerFound']),
|
||||
...mapState({
|
||||
champions: state => state.summoner.champions.list,
|
||||
championsLoaded: state => state.summoner.champions.championsLoaded,
|
||||
matchList: state => state.summoner.basic.matchList
|
||||
gamemodes: state => state.summoner.basic.gamemodes
|
||||
})
|
||||
},
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ export default {
|
|||
},
|
||||
filterByQueue(queue) {
|
||||
queue = Number(queue)
|
||||
this.queue = queue === -1 ? null : queue
|
||||
this.queue = queue === 0 ? null : queue
|
||||
this.championsRequest(this.queue)
|
||||
},
|
||||
updateSearch(search) {
|
||||
|
|
|
|||
|
|
@ -51,9 +51,11 @@ export default class SummonersController {
|
|||
finalJSON.matchList = await MatchService.updateMatchList(account, region, summonerDB)
|
||||
|
||||
// All seasons the summoner has played
|
||||
// TODO: check if there is a way to do that with V5...
|
||||
finalJSON.seasons = await this.getSeasons(account.puuid)
|
||||
|
||||
// All gamemodes the summoner has played
|
||||
finalJSON.gamemodes = (await MatchRepository.gamemodes(account.puuid)).map((g) => g.gamemode)
|
||||
|
||||
// CURRENT GAME
|
||||
console.time('playing')
|
||||
const currentGame = await Jax.Spectator.summonerID(account.id, region)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,20 @@ class MatchRepository {
|
|||
return query
|
||||
}
|
||||
|
||||
public async gamemodes(puuid: string) {
|
||||
const query = `
|
||||
SELECT DISTINCT
|
||||
matches.gamemode
|
||||
FROM
|
||||
match_players
|
||||
${this.JOIN_MATCHES}
|
||||
WHERE
|
||||
match_players.summoner_puuid = :puuid
|
||||
`
|
||||
const { rows } = await Database.rawQuery(query, { puuid })
|
||||
return rows
|
||||
}
|
||||
|
||||
public async seasons(puuid: string) {
|
||||
const query = `
|
||||
SELECT DISTINCT
|
||||
|
|
|
|||
Loading…
Reference in a new issue