From f138db27a5c8682601f28c4fa91f12e18f5ca73d Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Tue, 12 Nov 2019 21:03:02 +0100 Subject: [PATCH] fix: remove tutorial games from history --- server/app/Helpers/MatchHelper.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/app/Helpers/MatchHelper.js b/server/app/Helpers/MatchHelper.js index d3bfcae..84dca15 100644 --- a/server/app/Helpers/MatchHelper.js +++ b/server/app/Helpers/MatchHelper.js @@ -17,7 +17,7 @@ class MatchHelper { do { let newMatchList = (await Jax.Matchlist.accountID(account.accountId, index)).matches matchList = [...matchList, ...newMatchList] - alreadyIn = stopFetching(newMatchList) + alreadyIn = newMatchList.length === 0 || stopFetching(newMatchList) // If the match is made in another region : we stop fetching if (matchList[matchList.length - 1].platformId.toLowerCase() !== account.region) { alreadyIn = true; @@ -25,8 +25,15 @@ class MatchHelper { index += 100 } while (!alreadyIn); - // Remove matches from MatchList made in another region - matchList = matchList.filter(m => m.platformId.toLowerCase() === account.region) + // Remove matches from MatchList made in another region and tutorial games + const tutorialModes = [2000, 2010, 2020] + matchList = matchList + .filter(m => { + const sameRegion = m.platformId.toLowerCase() === account.region + const notATutorialGame = !tutorialModes.includes(m.queue) + + return sameRegion && notATutorialGame + }) return matchList } @@ -103,16 +110,9 @@ class MatchHelper { MatchHelper: this } - // matchesFromApi = await Bumblebee.create().collection(matchesFromApi) - // .transformWith(MatchTransformer) - // .withContext(ctx) - // .toJSON() - - console.time('newTransformer') matchesFromApi = matchesFromApi.map(m => { if (m) return BasicMatchTransformer.transform(m, ctx) }) - console.timeEnd('newTransformer') console.log(matchesFromApi.length) Logger.transport('file').info(matchesFromApi)