From 8aeb15806c1da608341c2809d299ab788a1b4f62 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Thu, 8 Feb 2024 04:34:16 -0800 Subject: [PATCH] fetching match data! --- index.mjs | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/index.mjs b/index.mjs index d042c3e..f56fb5e 100644 --- a/index.mjs +++ b/index.mjs @@ -11,9 +11,11 @@ const config = { client: "redis://redis:6379", // leave null if client is local ttls: { byMethod: { - [METHOD_KEY.SUMMONER.GET_BY_SUMMONER_NAME]: 24 * 60 * 60 * 100, // ms - [METHOD_KEY.MATCH_V5.GET_IDS_BY_PUUID]: 24 * 60 * 60 * 100, // ms - [METHOD_KEY.MATCH.GET_MATCHLIST_BY_ACCOUNT]: 24 * 60 * 60 * 100, // ms + [METHOD_KEY.SUMMONER.GET_BY_SUMMONER_NAME]: 24 * 60 * 60 * 100, // 1 day + [METHOD_KEY.MATCH_V5.GET_IDS_BY_PUUID]: 24 * 60 * 60 * 100, // 1 day + [METHOD_KEY.MATCH_V5.GET_MATCH_BY_ID]: 24 * 60 * 60 * 100, // 1 day + // TODO: Figure out if I can get more games with old API? + // [METHOD_KEY.MATCH.GET_MATCHLIST_BY_ACCOUNT]: 24 * 60 * 60 * 100, // ms }, }, }, @@ -35,13 +37,28 @@ const ice = await rAPI.summoner }) .then(({ name, puuid }) => ({ name, puuid })); -const valGames = await get_games_by_puuid(val.puuid); -const iceGames = await get_games_by_puuid(ice.puuid); +const valGameIds = await get_games_by_puuid(val.puuid); +const iceGamesIds = await get_games_by_puuid(ice.puuid); -const commonGames = valGames.filter(Set.prototype.has, new Set(iceGames)); +const commonGameIds = valGameIds.filter( + Set.prototype.has, + new Set(iceGamesIds), +); -console.log(`Common Games Found: ${commonGames.length}`); -console.log(`${JSON.stringify(commonGames, null, " ")}`); +console.log(`Common Games Found: ${commonGameIds.length}`); +console.log(`${JSON.stringify(commonGameIds, null, " ")}`); + +let commonGames = []; +for (const matchId of commonGameIds) { + const game = await rAPI.matchV5.getMatchById({ + cluster: PlatformId.AMERICAS, + matchId, + }); + + commonGames.push(game); + + console.log(JSON.stringify(game)); +} /** * @param {string} puuid