fix: remove games made in another region if player transfered

This commit is contained in:
Valentin Kaelin 2019-10-10 20:56:48 +02:00
parent 65185157a9
commit 18ccfeb21c
3 changed files with 9 additions and 1 deletions

View file

@ -25,6 +25,7 @@ class SummonerController {
const account = await Jax.Summoner.summonerName(summoner)
// Check if the summoner is found
if (!account) return response.json(null)
account.region = region
finalJSON.account = account
// RANKED STATS

View file

@ -21,9 +21,16 @@ class MatchHelper {
let newMatchList = (await Jax.Matchlist.accountID(account.accountId, index)).matches
matchList = [...matchList, ...newMatchList]
alreadyIn = stopFetching(newMatchList)
// If the match is made in another region : we stop fetching
if (matchList[matchList.length - 1].platformId.toLowerCase() !== account.region) {
alreadyIn = true;
}
index += 100
} while (!alreadyIn);
// Remove matches from MatchList made in another region
matchList = matchList.filter(m => m.platformId.toLowerCase() === account.region)
return matchList
}
/**