From 90ee71c9ca35b03c00ffe992de1461af51d44a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:19:13 -0600 Subject: [PATCH 1/3] fix: archived season number --- .../getArchivedLatestSeasonNumber.ts | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts b/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts index ba4a1a808..3e7cca876 100644 --- a/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts +++ b/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts @@ -1,17 +1,28 @@ import getRatingsInfo from '../blitz/getRatingsInfo'; +interface GitHubTrees { + tree: { path: string; url: string }[]; +} + let cachedLatestArchivedSeasonNumber: number | null = null; export async function getArchivedLatestSeasonNumber() { + if (cachedLatestArchivedSeasonNumber !== null) { + return cachedLatestArchivedSeasonNumber; + } + const ratingsInfo = await getRatingsInfo('com'); if (ratingsInfo.detail) { - const comURL = ( + const regionsURL = ( (await fetch( - 'https://api.github.com/repos/tresabhi/blitzkrieg-assets/git/trees/main/regions', - ).then((response) => response.json())) as { - tree: { path: string; url: string }[]; - } + 'https://api.github.com/repos/tresabhi/blitzkrieg-assets/git/trees/main', + ).then((response) => response.json())) as GitHubTrees + ).tree.find(({ path }) => path === 'regions')!.url; + const comURL = ( + (await fetch(regionsURL).then((response) => + response.json(), + )) as GitHubTrees ).tree.find(({ path }) => path === 'com')!.url; const ratingsURL = ( (await fetch(comURL).then((response) => response.json())) as { @@ -20,14 +31,16 @@ export async function getArchivedLatestSeasonNumber() { ).tree[0].url; const latestSeason = Math.max( ...( - (await fetch(ratingsURL).then((response) => { - response.json(); - })) as { tree: { path: string }[] } - ).tree.map(({ path }) => parseInt(path)), + (await fetch(ratingsURL).then((response) => response.json())) as { + tree: { path: string }[]; + } + ).tree.map(({ path }) => Number(path)), ); - return latestSeason; + cachedLatestArchivedSeasonNumber = latestSeason; } else { - return ratingsInfo.current_season - 1; + cachedLatestArchivedSeasonNumber = ratingsInfo.current_season - 1; } + + return cachedLatestArchivedSeasonNumber; } From fff42b61e1d81c842c412db711555383b7292d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:22:39 -0600 Subject: [PATCH 2/3] fix: deleted ratings players --- src/commands/ratings.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/ratings.tsx b/src/commands/ratings.tsx index 7fe6a5b23..f807ef7ff 100644 --- a/src/commands/ratings.tsx +++ b/src/commands/ratings.tsx @@ -298,8 +298,8 @@ export const ratingsCommand = new Promise( position: firstPlayerIndex + index + 1, clan: clanData[player.id]?.clan?.tag, nickname: - clanData[player.id]?.account_name ?? - `Unknown Player ${player.id}`, + clanData[index]?.account_name ?? + `Deleted ${player.id}`, }) satisfies SimplifiedPlayer, ); }, From fe562915cbe175ce4329ff4edee7e8c3bc0c7edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:24:45 -0600 Subject: [PATCH 3/3] feat: docs --- docs/changelogs/1.15.9.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 docs/changelogs/1.15.9.md diff --git a/docs/changelogs/1.15.9.md b/docs/changelogs/1.15.9.md new file mode 100644 index 000000000..f3c58e41e --- /dev/null +++ b/docs/changelogs/1.15.9.md @@ -0,0 +1,13 @@ +# Blitzkrieg 1.15.9 + +~~Curiosity killed the cat~~ Ratings killed the Blitzkrieg + +## Fixes + +- Deleted ratings players are now handled properly + +## Technical Fixes + +- Latest archived season number + - Is now cached properly + - Is now fetched in a chaining fashion correctly diff --git a/package.json b/package.json index 8a933ceb9..d7d12bb84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.8", + "version": "1.15.9", "description": "🎉 Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module",