more data viewssss

This commit is contained in:
Zynh0722 2024-02-08 19:41:40 -08:00
parent 902e8775a7
commit 82108a0f3f
3 changed files with 56 additions and 10 deletions

View file

@ -10,7 +10,7 @@ services:
- NODE_ENV=production - NODE_ENV=production
volumes: volumes:
- ./:/home/node/app - ./:/home/node/app
command: "npx nodemon --exec npm start" command: "npx nodemon --exec npm run debug-cache"
depends_on: depends_on:
- redis - redis

View file

@ -16,9 +16,9 @@ const config = {
client: "redis://redis:6379", // leave null if client is local client: "redis://redis:6379", // leave null if client is local
ttls: { ttls: {
byMethod: { byMethod: {
[METHOD_KEY.SUMMONER.GET_BY_SUMMONER_NAME]: 24 * 60 * 60 * 100, // 1 day [METHOD_KEY.SUMMONER.GET_BY_SUMMONER_NAME]: 7 * 24 * 60 * 60 * 1000, // 7 day
[METHOD_KEY.MATCH_V5.GET_IDS_BY_PUUID]: 24 * 60 * 60 * 100, // 1 day [METHOD_KEY.MATCH_V5.GET_IDS_BY_PUUID]: 7 * 24 * 60 * 60 * 1000, // 7 day
[METHOD_KEY.MATCH_V5.GET_MATCH_BY_ID]: 24 * 60 * 60 * 100, // 1 day [METHOD_KEY.MATCH_V5.GET_MATCH_BY_ID]: 7 * 24 * 60 * 60 * 1000, // 7 day
// TODO: Figure out if I can get more games with old API? // TODO: Figure out if I can get more games with old API?
// [METHOD_KEY.MATCH.GET_MATCHLIST_BY_ACCOUNT]: 24 * 60 * 60 * 100, // ms // [METHOD_KEY.MATCH.GET_MATCHLIST_BY_ACCOUNT]: 24 * 60 * 60 * 100, // ms
}, },
@ -61,11 +61,11 @@ for (const matchId of commonGameIds) {
commonGames.push(game); commonGames.push(game);
} }
console.log(`Common Game Data Found: ${commonGameIds.length}`); console.log(`\nCommon Game Data Found: ${commonGameIds.length}`);
commonGames.reverse(); commonGames.reverse();
let gameData = commonGames let gameData0 = commonGames
.map(({ info, metadata }) => ({ .map(({ info, metadata }) => ({
id: metadata.matchId, id: metadata.matchId,
data: info.participants data: info.participants
@ -116,20 +116,65 @@ let gameData = commonGames
...rest, ...rest,
win: data[0].win, win: data[0].win,
data: data.reduce((acc, playerData) => { data: data.reduce((acc, playerData) => {
acc[playerData.summonerName] = playerData.positionEstimate; acc[playerData.summonerName] = {
position: playerData.positionEstimate,
champion: playerData.championName,
};
return acc; return acc;
}, {}), }, {}),
}; };
}); });
gameData.forEach((g) => console.log(JSON.stringify(g, null, " "))); console.log(`\nBot Lane Duo Matches Found: ${gameData0.length}`);
const wins0 = gameData0.filter(({ win }) => win).length;
const losses0 = gameData0.filter(({ win }) => !win).length;
console.log(`Wins: ${wins0}`);
console.log(`Losses: ${losses0}`);
console.log(`W/L: ${(wins0 / (wins0 + losses0)).toFixed(2)}`);
let gameData = gameData0.filter(
({ data }) => data["RavenShade"].champion !== "Smolder",
);
console.log(`\nBot Lane Duo Matches Found (No Smolder): ${gameData.length}`);
const rawWins = gameData.filter(({ win }) => win);
const rawLosses = gameData.filter(({ win }) => !win);
const winData = rawWins.map((win) => win.data);
const lossData = rawLosses.map((loss) => loss.data);
const wins = rawWins.length;
const losses = rawLosses.length;
console.log(`Wins: ${wins}`);
console.log(`Losses: ${losses}`);
console.log(`W/L: ${(wins / (wins + losses)).toFixed(2)}`);
console.log("\nwins");
winData
.map((d) =>
Object.entries(d).map(([summoner, { champion }]) => ({
summoner,
champion,
})),
)
.forEach((g) => console.log(JSON.stringify(g, null, "")));
console.log("\nlosses");
lossData
.map((d) =>
Object.entries(d).map(([summoner, { champion }]) => ({
summoner,
champion,
})),
)
.forEach((g) => console.log(JSON.stringify(g, null, "")));
/** /**
* @param {string} puuid * @param {string} puuid
* @returns {Promise<string[]>} * @returns {Promise<string[]>}
*/ */
async function get_games_by_puuid(puuid) { async function get_games_by_puuid(puuid) {
const COUNT = 100; const COUNT = 20;
let games = []; let games = [];

View file

@ -5,7 +5,8 @@
"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",
"debug-cache": "DEBUG=riotapi* node --no-deprecation index.mjs"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",