From 341893fdb7b8ba3bb99ae92738a5b6b02059ccfd Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Thu, 8 Feb 2024 16:52:26 -0800 Subject: [PATCH] fixing keys and filter for draft pick --- .gitignore | 1 + example.env | 1 + index.mjs | 17 +++++++++++++---- package-lock.json | 14 +++++++++++++- package.json | 5 +++-- 5 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 example.env diff --git a/.gitignore b/.gitignore index c2658d7..713d500 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +.env diff --git a/example.env b/example.env new file mode 100644 index 0000000..a2b4852 --- /dev/null +++ b/example.env @@ -0,0 +1 @@ +RG_API_KEY=api_key_here diff --git a/index.mjs b/index.mjs index 25e1b8a..10f8d92 100644 --- a/index.mjs +++ b/index.mjs @@ -1,6 +1,11 @@ // @ts-check import { RiotAPI, RiotAPITypes, PlatformId } from "@fightmegg/riot-api"; +import "dotenv/config"; + +/** @type {string} */ +const RG_API_KEY = process.env.RG_API_KEY || "no api key found"; + const METHOD_KEY = RiotAPITypes.METHOD_KEY; /** @type {RiotAPITypes.Config} */ @@ -21,7 +26,7 @@ const config = { }, }; -const rAPI = new RiotAPI("RGAPI-8f41294d-7bb1-4fd5-83d4-773a8a7b25f5", config); +const rAPI = new RiotAPI(RG_API_KEY, config); let val = await rAPI.summoner .getBySummonerName({ @@ -45,8 +50,6 @@ const commonGameIds = valGameIds.filter( new Set(iceGamesIds), ); -// console.log(`${JSON.stringify(commonGameIds, null, " ")}`); - /** @type {RiotAPITypes.MatchV5.MatchDTO[]} */ let commonGames = []; for (const matchId of commonGameIds) { @@ -65,6 +68,7 @@ commonGames.reverse(); commonGames .map(({ info, metadata }) => ({ id: metadata.matchId, + queueId: info.queueId, data: info.participants .filter(({ puuid }) => puuid === ice.puuid || puuid === val.puuid) .map(({ championId, championName, summonerName, lane }) => ({ @@ -74,6 +78,7 @@ commonGames lane, })), })) + .filter((g) => g.queueId !== 400) // .filter(({ data }) => { // const lanes = data.map((s) => s.lane); // return lanes.includes("BOTTOM") && lanes.includes("SUPPORT"); @@ -85,6 +90,8 @@ commonGames * @returns {Promise} */ async function get_games_by_puuid(puuid) { + const COUNT = 100; + let games = []; let start = 0; @@ -94,6 +101,8 @@ async function get_games_by_puuid(puuid) { puuid, params: { start, + count: COUNT, + queue: 400, }, }); @@ -103,7 +112,7 @@ async function get_games_by_puuid(puuid) { games.push.apply(games, newGames); - start += 20; + start += COUNT; } return games; diff --git a/package-lock.json b/package-lock.json index ab48fc4..f0386ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@fightmegg/riot-api": "^0.0.18" + "@fightmegg/riot-api": "^0.0.18", + "dotenv": "^16.4.1" }, "devDependencies": { "nodemon": "^3.0.3" @@ -167,6 +168,17 @@ "node": ">=0.10" } }, + "node_modules/dotenv": { + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.1.tgz", + "integrity": "sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", diff --git a/package.json b/package.json index 48bd691..a1c215f 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,13 @@ "main": "index.mjs", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "node --no-deprecation index.mjs" + "start": "DEBUG=riotapi* node --no-deprecation index.mjs" }, "author": "", "license": "MIT", "dependencies": { - "@fightmegg/riot-api": "^0.0.18" + "@fightmegg/riot-api": "^0.0.18", + "dotenv": "^16.4.1" }, "devDependencies": { "nodemon": "^3.0.3"