fetching common game ids

This commit is contained in:
Zynh0722 2024-02-08 04:15:34 -08:00
parent 45a8083857
commit b3b6fbdb9e
2 changed files with 4 additions and 11 deletions

View file

@ -5,6 +5,7 @@ const METHOD_KEY = RiotAPITypes.METHOD_KEY;
/** @type {RiotAPITypes.Config} */ /** @type {RiotAPITypes.Config} */
const config = { const config = {
debug: false,
cache: { cache: {
cacheType: "ioredis", // local or ioredis cacheType: "ioredis", // local or ioredis
client: "redis://redis:6379", // leave null if client is local client: "redis://redis:6379", // leave null if client is local
@ -34,14 +35,12 @@ const ice = await rAPI.summoner
}) })
.then(({ name, puuid }) => ({ name, puuid })); .then(({ name, puuid }) => ({ name, puuid }));
console.log(`${JSON.stringify(val, null, " ")}`);
console.log(`${JSON.stringify(ice, null, " ")}`);
const valGames = await get_games_by_puuid(val.puuid); const valGames = await get_games_by_puuid(val.puuid);
const iceGames = await get_games_by_puuid(ice.puuid); const iceGames = await get_games_by_puuid(ice.puuid);
const commonGames = valGames.filter(Set.prototype.has, new Set(iceGames)); const commonGames = valGames.filter(Set.prototype.has, new Set(iceGames));
console.log(`Common Games Found: ${commonGames.length}`);
console.log(`${JSON.stringify(commonGames, null, " ")}`); console.log(`${JSON.stringify(commonGames, null, " ")}`);
/** /**
@ -53,10 +52,9 @@ async function get_games_by_puuid(puuid) {
let start = 0; let start = 0;
while (start >= 0) { while (start >= 0) {
console.log(`getting entries ${start}-${start + 19}`);
let newGames = await rAPI.matchV5.getIdsByPuuid({ let newGames = await rAPI.matchV5.getIdsByPuuid({
cluster: PlatformId.AMERICAS, cluster: PlatformId.AMERICAS,
puuid: val.puuid, puuid,
params: { params: {
start, start,
}, },

View file

@ -5,7 +5,7 @@
"main": "index.mjs", "main": "index.mjs",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "DEBUG=riotapi* node --no-deprecation index.mjs" "start": "node --no-deprecation index.mjs"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
@ -14,10 +14,5 @@
}, },
"devDependencies": { "devDependencies": {
"nodemon": "^3.0.3" "nodemon": "^3.0.3"
},
"nodemonConfig": {
"env": {
"DEBUG": "riotapi*"
}
} }
} }