more data viewssss
This commit is contained in:
parent
902e8775a7
commit
82108a0f3f
3 changed files with 56 additions and 10 deletions
|
@ -10,7 +10,7 @@ services:
|
|||
- NODE_ENV=production
|
||||
volumes:
|
||||
- ./:/home/node/app
|
||||
command: "npx nodemon --exec npm start"
|
||||
command: "npx nodemon --exec npm run debug-cache"
|
||||
depends_on:
|
||||
- redis
|
||||
|
||||
|
|
61
index.mjs
61
index.mjs
|
@ -16,9 +16,9 @@ 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, // 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
|
||||
[METHOD_KEY.SUMMONER.GET_BY_SUMMONER_NAME]: 7 * 24 * 60 * 60 * 1000, // 7 day
|
||||
[METHOD_KEY.MATCH_V5.GET_IDS_BY_PUUID]: 7 * 24 * 60 * 60 * 1000, // 7 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?
|
||||
// [METHOD_KEY.MATCH.GET_MATCHLIST_BY_ACCOUNT]: 24 * 60 * 60 * 100, // ms
|
||||
},
|
||||
|
@ -61,11 +61,11 @@ for (const matchId of commonGameIds) {
|
|||
commonGames.push(game);
|
||||
}
|
||||
|
||||
console.log(`Common Game Data Found: ${commonGameIds.length}`);
|
||||
console.log(`\nCommon Game Data Found: ${commonGameIds.length}`);
|
||||
|
||||
commonGames.reverse();
|
||||
|
||||
let gameData = commonGames
|
||||
let gameData0 = commonGames
|
||||
.map(({ info, metadata }) => ({
|
||||
id: metadata.matchId,
|
||||
data: info.participants
|
||||
|
@ -116,20 +116,65 @@ let gameData = commonGames
|
|||
...rest,
|
||||
win: data[0].win,
|
||||
data: data.reduce((acc, playerData) => {
|
||||
acc[playerData.summonerName] = playerData.positionEstimate;
|
||||
acc[playerData.summonerName] = {
|
||||
position: playerData.positionEstimate,
|
||||
champion: playerData.championName,
|
||||
};
|
||||
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
|
||||
* @returns {Promise<string[]>}
|
||||
*/
|
||||
async function get_games_by_puuid(puuid) {
|
||||
const COUNT = 100;
|
||||
const COUNT = 20;
|
||||
|
||||
let games = [];
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"main": "index.mjs",
|
||||
"scripts": {
|
||||
"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": "",
|
||||
"license": "MIT",
|
||||
|
|
Loading…
Reference in a new issue