From c1ecef01796d9162b703dd755372691818613a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 19 Nov 2023 13:55:11 -0600 Subject: [PATCH 01/28] fix: add max target position --- package.json | 2 +- src/app/tools/ratings/page.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index cc2eefeac..7342591a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.1", + "version": "1.15.2", "description": "๐ŸŽ‰ Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", diff --git a/src/app/tools/ratings/page.tsx b/src/app/tools/ratings/page.tsx index fe70ff97f..0b8c5ac7a 100644 --- a/src/app/tools/ratings/page.tsx +++ b/src/app/tools/ratings/page.tsx @@ -347,9 +347,9 @@ export default function Page() { async function jumpToPosition(position: number) { if (!ratingsInfo || ratingsInfo?.detail) return; - const targetPosition = Math.max( - 0, - Math.min(position, ratingsInfo.count - 1), + const targetPosition = Math.min( + ratingsInfo.count - 1, + Math.max(0, Math.min(position, ratingsInfo.count - 1)), ); if (season === 0) { From 7baaaa9db949aa887bb1d003fe4431cd28bd7c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:02:00 -0600 Subject: [PATCH 02/28] fix: remove seeding player neighbor checking --- src/app/tools/ratings/page.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/tools/ratings/page.tsx b/src/app/tools/ratings/page.tsx index 0b8c5ac7a..979e4c1c3 100644 --- a/src/app/tools/ratings/page.tsx +++ b/src/app/tools/ratings/page.tsx @@ -299,19 +299,11 @@ export default function Page() { } } - const seedingPlayerNeighborEntry = Object.entries( - leaderboard[region][season], - ).find(([, player]) => id === player); - - if (seedingPlayerNeighborEntry === undefined) return null; - - // const seedingPlayerPosition = parseInt(seedingPlayerNeighborEntry[0]); const { neighbors } = await getRatingsNeighbors(region, id, size, true); useLeaderboardCache.setState( produce((draft: LeaderboardCache) => { neighbors.forEach((neighbor, neighborIndex) => { - // const position = neighborIndex - radius + seedingPlayerPosition; const position = neighbor.number - 1; if (!(position in draft[region][season])) { From 11706761413469a77d2ad2338b7bbd7034f4fa3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 19 Nov 2023 14:05:39 -0600 Subject: [PATCH 03/28] feat: changelogs --- docs/changelogs/1.15.2.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/changelogs/1.15.2.md diff --git a/docs/changelogs/1.15.2.md b/docs/changelogs/1.15.2.md new file mode 100644 index 000000000..4f95b9741 --- /dev/null +++ b/docs/changelogs/1.15.2.md @@ -0,0 +1,9 @@ +# Blitzkrieg 1.15.2 + +Infinity reduced to a finite value. + +## Fixes + +- Added a maximum value to the jump to position button +- Removed neighbor checking for the seeding player + - This fixes the jump to position button not loading at all From 396b48d0170e4745ce89607c1fe30a8adc62392e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 20 Nov 2023 13:32:53 -0600 Subject: [PATCH 04/28] feat: smaller fetching size --- scripts/buildRatingsLeaderboard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index 564bffb66..c137f3e5d 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -28,7 +28,7 @@ const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1]; if (!server) throw new Error('Region parameter not specified'); -const NEIGHBORS = 1024; +const NEIGHBORS = 2 ** 8; const PLAYERS = await patientFetchJSON( `https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`, ).then((data) => (data.detail === undefined ? data.count : undefined)); From 42091c54b7e72d03a8ee698084a8b5482316ce20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:49:24 -0600 Subject: [PATCH 05/28] fix: illegal json invocation --- src/core/blitzkrieg/patientFetchJSON.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/blitzkrieg/patientFetchJSON.ts b/src/core/blitzkrieg/patientFetchJSON.ts index c96b4dc83..de3a31105 100644 --- a/src/core/blitzkrieg/patientFetchJSON.ts +++ b/src/core/blitzkrieg/patientFetchJSON.ts @@ -7,8 +7,8 @@ export async function patientFetchJSON( while (patientJSON! === undefined) { try { - patientJSON = (await fetch(url, options).then(({ json }) => - json(), + patientJSON = (await fetch(url, options).then((response) => + response.json(), )) as Type; } catch (error) { console.warn( From 7c76b0f5a5be01ded5a0241c81b55fbbe63b2277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:51:52 -0600 Subject: [PATCH 06/28] feat: Asia leaderboard manual trigger --- .github/workflows/cd-asia-ratings-latest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml index 9be005f72..b3c1a2598 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -3,6 +3,7 @@ name: CD Asia Ratings Latest on: schedule: - cron: "0 0 * * *" + workflow_dispatch: jobs: host: From c0ac935652205f31ccc6239ca8494b94a986fd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:36:40 -0600 Subject: [PATCH 07/28] feat: remove manual asia leaderboard trigger --- .github/workflows/cd-asia-ratings-latest.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml index b3c1a2598..85ba74d8f 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -2,8 +2,7 @@ name: CD Asia Ratings Latest on: schedule: - - cron: "0 0 * * *" - workflow_dispatch: + - cron: '0 0 * * *' jobs: host: @@ -17,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -25,7 +24,7 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies From 1afe860e76577fc0ec246d07df9f6fdaee0e98df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:38:04 -0600 Subject: [PATCH 08/28] feat: change workflow file name to midnight --- ...asia-ratings-leaderboards.yml => cd-asia-ratings-midnight.yml} | 0 ...{cd-eu-ratings-leaderboards.yml => cd-eu-ratings-midnight.yml} | 0 ...{cd-na-ratings-leaderboards.yml => cd-na-ratings-midnight.yml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cd-asia-ratings-leaderboards.yml => cd-asia-ratings-midnight.yml} (100%) rename .github/workflows/{cd-eu-ratings-leaderboards.yml => cd-eu-ratings-midnight.yml} (100%) rename .github/workflows/{cd-na-ratings-leaderboards.yml => cd-na-ratings-midnight.yml} (100%) diff --git a/.github/workflows/cd-asia-ratings-leaderboards.yml b/.github/workflows/cd-asia-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-asia-ratings-leaderboards.yml rename to .github/workflows/cd-asia-ratings-midnight.yml diff --git a/.github/workflows/cd-eu-ratings-leaderboards.yml b/.github/workflows/cd-eu-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-eu-ratings-leaderboards.yml rename to .github/workflows/cd-eu-ratings-midnight.yml diff --git a/.github/workflows/cd-na-ratings-leaderboards.yml b/.github/workflows/cd-na-ratings-midnight.yml similarity index 100% rename from .github/workflows/cd-na-ratings-leaderboards.yml rename to .github/workflows/cd-na-ratings-midnight.yml From 06cbcc23395376d8a505672f35cabe5fa40e9607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 23 Nov 2023 14:39:04 -0600 Subject: [PATCH 09/28] fix: "Midnight" in name --- .github/workflows/cd-asia-ratings-midnight.yml | 2 +- .github/workflows/cd-eu-ratings-midnight.yml | 2 +- .github/workflows/cd-na-ratings-midnight.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-asia-ratings-midnight.yml index 2462e4601..ebad9ad1a 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-asia-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD Asia Ratings Leaderboards +name: CD Asia Ratings Midnight on: schedule: diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-eu-ratings-midnight.yml index c026c483d..da778b527 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-eu-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD Europe Ratings Leaderboards +name: CD Europe Ratings Midnight on: schedule: diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml index 414e143a3..1426f7c31 100644 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ b/.github/workflows/cd-na-ratings-midnight.yml @@ -1,4 +1,4 @@ -name: CD North America Ratings Leaderboards +name: CD North America Ratings Midnight on: schedule: From 55729c5eda0a68045c1a4f546d2f877e20cc32bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:46:56 -0600 Subject: [PATCH 10/28] feat: ratings leaderboard archive explicit target --- .github/workflows/cd-asia-ratings-latest.yml | 2 +- .github/workflows/cd-asia-ratings-midnight.yml | 8 ++++---- .github/workflows/cd-eu-ratings-latest.yml | 8 ++++---- .github/workflows/cd-eu-ratings-midnight.yml | 8 ++++---- .github/workflows/cd-na-ratings-latest.yml | 2 +- .github/workflows/cd-na-ratings-midnight.yml | 2 +- scripts/buildRatingsLeaderboard.ts | 9 +++++---- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml index 85ba74d8f..93b327a33 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=latest diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-asia-ratings-midnight.yml index ebad9ad1a..2c4426498 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-asia-ratings-midnight.yml @@ -2,7 +2,7 @@ name: CD Asia Ratings Midnight on: schedule: - - cron: "0 17 * * *" + - cron: '0 17 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=midnight diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml index c988ee70e..dbcd36cb1 100644 --- a/.github/workflows/cd-eu-ratings-latest.yml +++ b/.github/workflows/cd-eu-ratings-latest.yml @@ -2,7 +2,7 @@ name: CD Europe Ratings Latest on: schedule: - - cron: "0 0 * * *" + - cron: '0 0 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=latest diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-eu-ratings-midnight.yml index da778b527..3c0b88eed 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-eu-ratings-midnight.yml @@ -2,7 +2,7 @@ name: CD Europe Ratings Midnight on: schedule: - - cron: "0 23 * * *" + - cron: '0 23 * * *' jobs: host: @@ -16,7 +16,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "npm" + cache: 'npm' - name: Install Yarn run: npm install --location=global yarn @@ -24,11 +24,11 @@ jobs: - name: Use node_modules cache uses: actions/cache@v3 with: - path: "**/node_modules" + path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=midnight diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml index ff7ab3470..5b98bc8c7 100644 --- a/.github/workflows/cd-na-ratings-latest.yml +++ b/.github/workflows/cd-na-ratings-latest.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=latest diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml index 1426f7c31..23249a2d4 100644 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ b/.github/workflows/cd-na-ratings-midnight.yml @@ -31,4 +31,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=midnight diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index c137f3e5d..a84929c02 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -23,9 +23,12 @@ export type BlitzkriegRatingsLeaderboardEntry = { id: number; score: number }; export type BlitzkriegRatingsLeaderboard = BlitzkriegRatingsLeaderboardEntry[]; const publish = argv.includes('--publish'); -const latest = argv.includes('--latest'); +const target = argv + .find((arg) => arg.startsWith('--target=')) + ?.split('=')[1] as 'midnight' | 'latest' | undefined; const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1]; +if (!target) throw new Error('Target parameter not specified'); if (!server) throw new Error('Region parameter not specified'); const NEIGHBORS = 2 ** 8; @@ -117,9 +120,7 @@ if (publish) { const normalizedServer = server === 'na' ? 'com' : server; const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`; - const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${ - latest ? 'latest' : 'midnight' - }.json`; + const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${target}.json`; const infoJSON = JSON.stringify(info); console.log(`Publishing to season ${info.current_season}...`); From c87a75f3fd7ef332617c9d01a8dad651d99af892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:01:12 -0600 Subject: [PATCH 11/28] feat: combined ratings archive workflows --- .github/workflows/cd-eu-ratings-latest.yml | 34 ------------------- .github/workflows/cd-na-ratings-latest.yml | 34 ------------------- .github/workflows/cd-na-ratings-midnight.yml | 34 ------------------- ...tings-midnight.yml => cd-ratings-asia.yml} | 8 +++-- ...ratings-midnight.yml => cd-ratings-eu.yml} | 8 +++-- ...a-ratings-latest.yml => cd-ratings-na.yml} | 8 +++-- 6 files changed, 18 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/cd-eu-ratings-latest.yml delete mode 100644 .github/workflows/cd-na-ratings-latest.yml delete mode 100644 .github/workflows/cd-na-ratings-midnight.yml rename .github/workflows/{cd-asia-ratings-midnight.yml => cd-ratings-asia.yml} (77%) rename .github/workflows/{cd-eu-ratings-midnight.yml => cd-ratings-eu.yml} (77%) rename .github/workflows/{cd-asia-ratings-latest.yml => cd-ratings-na.yml} (76%) diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml deleted file mode 100644 index dbcd36cb1..000000000 --- a/.github/workflows/cd-eu-ratings-latest.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD Europe Ratings Latest - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=latest diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml deleted file mode 100644 index 5b98bc8c7..000000000 --- a/.github/workflows/cd-na-ratings-latest.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD North America Ratings Latest - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=latest diff --git a/.github/workflows/cd-na-ratings-midnight.yml b/.github/workflows/cd-na-ratings-midnight.yml deleted file mode 100644 index 23249a2d4..000000000 --- a/.github/workflows/cd-na-ratings-midnight.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CD North America Ratings Midnight - -on: - schedule: - - cron: '0 5 * * *' - -jobs: - host: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'npm' - - - name: Install Yarn - run: npm install --location=global yarn - - - name: Use node_modules cache - uses: actions/cache@v3 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - - name: Install dependencies - run: yarn - - - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=midnight diff --git a/.github/workflows/cd-asia-ratings-midnight.yml b/.github/workflows/cd-ratings-asia.yml similarity index 77% rename from .github/workflows/cd-asia-ratings-midnight.yml rename to .github/workflows/cd-ratings-asia.yml index 2c4426498..6135fc719 100644 --- a/.github/workflows/cd-asia-ratings-midnight.yml +++ b/.github/workflows/cd-ratings-asia.yml @@ -1,7 +1,11 @@ -name: CD Asia Ratings Midnight +name: CD Asia Ratings + +# latest: '0 0 * * *' +# asia midnight: '0 17 * * *' on: schedule: + - cron: '0 0 * * *' - cron: '0 17 * * *' jobs: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=midnight + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} diff --git a/.github/workflows/cd-eu-ratings-midnight.yml b/.github/workflows/cd-ratings-eu.yml similarity index 77% rename from .github/workflows/cd-eu-ratings-midnight.yml rename to .github/workflows/cd-ratings-eu.yml index 3c0b88eed..b0f0d0a78 100644 --- a/.github/workflows/cd-eu-ratings-midnight.yml +++ b/.github/workflows/cd-ratings-eu.yml @@ -1,7 +1,11 @@ -name: CD Europe Ratings Midnight +name: CD Europe Ratings + +# latest: '0 0 * * *' +# eu midnight: '0 23 * * *' on: schedule: + - cron: '0 0 * * *' - cron: '0 23 * * *' jobs: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=midnight + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-ratings-na.yml similarity index 76% rename from .github/workflows/cd-asia-ratings-latest.yml rename to .github/workflows/cd-ratings-na.yml index 93b327a33..8c91f1600 100644 --- a/.github/workflows/cd-asia-ratings-latest.yml +++ b/.github/workflows/cd-ratings-na.yml @@ -1,8 +1,12 @@ -name: CD Asia Ratings Latest +name: CD North America Ratings + +# latest: '0 0 * * *' +# na midnight: '0 5 * * *' on: schedule: - cron: '0 0 * * *' + - cron: '0 5 * * *' jobs: host: @@ -31,4 +35,4 @@ jobs: run: yarn - name: Generate leaderboard - run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --target=latest + run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --target=${{ github.event.schedule == '0 0 * * *' && 'latest' || 'midnight' }} From a3e20501af8f1913f564137f2224bb83cfc53b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:08:01 -0600 Subject: [PATCH 12/28] feat: new credits transfer --- docs/guide/creators.md | 6 ++++++ src/commands/about.ts | 2 ++ src/commands/credits.ts | 15 --------------- src/events/interactionCreate/index.ts | 2 -- 4 files changed, 8 insertions(+), 17 deletions(-) create mode 100644 docs/guide/creators.md delete mode 100644 src/commands/credits.ts diff --git a/docs/guide/creators.md b/docs/guide/creators.md new file mode 100644 index 000000000..663fb39ab --- /dev/null +++ b/docs/guide/creators.md @@ -0,0 +1,6 @@ +# Creators + +- TrรจsAbhi `@tresabhi` + - Creator & main programmer; _I do it all!_ +- Prince_NA `@prince_na` + - Advisor & tester diff --git a/src/commands/about.ts b/src/commands/about.ts index 63fbc6aa0..94b60fbf0 100644 --- a/src/commands/about.ts +++ b/src/commands/about.ts @@ -11,6 +11,7 @@ const DOCS = { introduction: 'guide/introduction', invite: 'guide/invite', timezones: 'guide/timezones', + creators: 'guide/creators', }; const DOC_DESCRIPTIONS: Record = { permissions: 'The permissions needed for the bot to function', @@ -18,6 +19,7 @@ const DOC_DESCRIPTIONS: Record = { introduction: 'About the bot', invite: 'How to invite the bot', timezones: 'How Blitzkrieg infers and uses your timezone', + creators: 'Who created the bot', }; function addDocsSubcommands(option: SlashCommandSubcommandsOnlyBuilder) { diff --git a/src/commands/credits.ts b/src/commands/credits.ts deleted file mode 100644 index 9cbe952d1..000000000 --- a/src/commands/credits.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { AttachmentBuilder, SlashCommandBuilder } from 'discord.js'; -import { CommandRegistry } from '../events/interactionCreate'; - -export const creditsCommand: CommandRegistry = { - inProduction: true, - inPublic: true, - - command: new SlashCommandBuilder() - .setName('credits') - .setDescription('Me and the people who made this bot'), - - async handler() { - return new AttachmentBuilder('https://i.imgur.com/ZF5ch33.png'); - }, -}; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 6dedea8b9..0b7aeadcb 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -16,7 +16,6 @@ import { import discord from '../../../discord.json' assert { type: 'json' }; import { aboutCommand } from '../../commands/about'; import { breakdownCommand } from '../../commands/breakdown'; -import { creditsCommand } from '../../commands/credits'; import { debugCommand } from '../../commands/debug'; import { eligibleCommand } from '../../commands/eligible'; import { evolutionCommand } from '../../commands/evolution'; @@ -102,7 +101,6 @@ export const COMMANDS_RAW: CommandRegistry[] = [ evolutionCommand, statsCommand, ratingsCommand, - creditsCommand, ]; export const commands = Promise.all(COMMANDS_RAW).then((rawCommands) => From debaaccf4cea61142ef759d60ef7779698ab2e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:40:11 -0600 Subject: [PATCH 13/28] feat: presence --- .vscode/settings.json | 1 + src/core/discord/client.ts | 3 ++- src/events/ready.ts | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 45f0cf251..1c0d191e7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "fuzzysort", "immer", "kranvagn", + "krieg", "Leaderboard", "leaderboards", "MURICA", diff --git a/src/core/discord/client.ts b/src/core/discord/client.ts index d79c653d5..3b9e6bbd8 100644 --- a/src/core/discord/client.ts +++ b/src/core/discord/client.ts @@ -1,10 +1,11 @@ import { Client, GatewayIntentBits } from 'discord.js'; import guildMemberAdd from '../../events/guildMemberAdd'; import interactionCreate from '../../events/interactionCreate'; +import ready from '../../events/ready'; export const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers], }) - // .on('ready', ready) + .on('ready', ready) .on('guildMemberAdd', guildMemberAdd) .on('interactionCreate', interactionCreate); diff --git a/src/events/ready.ts b/src/events/ready.ts index 3c24d0ab2..d589d2941 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,5 +1,23 @@ -import { Client } from 'discord.js'; +import { ActivityType, Client } from 'discord.js'; export default function ready(client: Client) { - console.log(`๐ŸŸข Launched bot ${client.shard?.ids[0]}`); + console.log(`๐ŸŸข Launched bot ${client.shard?.ids[0] ?? 'default'}`); + + const activities: (() => string)[] = [ + () => `Living in ${client.guilds.cache.size.toLocaleString()} servers`, + () => + `Serving ${client.guilds.cache + .reduce((accumulator, guild) => accumulator + guild.memberCount, 0) + .toLocaleString()} users`, + () => `Observing ${client.channels.cache.size.toLocaleString()} channels`, + ]; + + client.user.setPresence({ + activities: [ + { + type: ActivityType.Custom, + name: activities[Math.floor(Math.random() * activities.length)](), + }, + ], + }); } From f5425d0e546504ade1907e4b1258c92d7941bacf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:45:00 -0600 Subject: [PATCH 14/28] fix: more accurate user count --- src/events/ready.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index d589d2941..d63ceeb31 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -5,10 +5,7 @@ export default function ready(client: Client) { const activities: (() => string)[] = [ () => `Living in ${client.guilds.cache.size.toLocaleString()} servers`, - () => - `Serving ${client.guilds.cache - .reduce((accumulator, guild) => accumulator + guild.memberCount, 0) - .toLocaleString()} users`, + () => `Serving ${client.users.cache.size.toLocaleString()} users`, () => `Observing ${client.channels.cache.size.toLocaleString()} channels`, ]; From f728751fa90387b522100755f176bd040a0b71e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:46:20 -0600 Subject: [PATCH 15/28] feat: better debug --- src/commands/debug.ts | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/commands/debug.ts b/src/commands/debug.ts index 7b1254add..70ac62ad9 100644 --- a/src/commands/debug.ts +++ b/src/commands/debug.ts @@ -1,11 +1,6 @@ import { SlashCommandBuilder } from 'discord.js'; import packageJSON from '../../package.json' assert { type: 'json' }; -import getClientId from '../core/blitzkrieg/getClientId'; -import { tankAverages } from '../core/blitzstars/tankAverages'; -import { tankopedia } from '../core/blitzstars/tankopedia'; import { client } from '../core/discord/client'; -import embedInfo from '../core/discord/embedInfo'; -import markdownTable from '../core/discord/markdownTable'; import { CommandRegistry } from '../events/interactionCreate'; const executionStart = new Date().getTime(); @@ -21,24 +16,21 @@ export const debugCommand: CommandRegistry = { async handler(interaction) { const currentTime = new Date().getTime(); const uptime = currentTime - executionStart; + const list = [ + ['Version', packageJSON.version], + ['Shard', client.shard?.ids[0] ?? 'default'], + [ + 'Uptime', + `${Math.floor((uptime / 1000 / 60 / 60) % 24)}h ${Math.floor( + (uptime / 1000 / 60) % 60, + )}m ${Math.floor((uptime / 1000) % 60)}s ${Math.floor( + uptime % 1000, + )}ms`, + ], + ] + .map(([key, value]) => `- ${key}: ${value}`) + .join('\n'); - return embedInfo( - `${client.user?.username} debug information`, - markdownTable([ - ['Version', packageJSON.version], - ['Client ID', getClientId()], - ['Tag', interaction.client.user.tag], - [ - 'Uptime', - `${Math.floor(uptime / 1000 / 60 / 60 / 24)}d ${Math.floor( - (uptime / 1000 / 60 / 60) % 24, - )}h ${Math.floor((uptime / 1000 / 60) % 60)}m ${Math.floor( - (uptime / 1000) % 60, - )}s ${Math.floor(uptime % 1000)}ms`, - ], - ['Tankopedia cached', `${(await tankopedia) !== undefined}`], - ['Tank averages cached', `${(await tankAverages) !== undefined}`], - ]), - ); + return `# Debug\n\n${list}`; }, }; From 3bbbbfa402b232152b07815a860f22d9d33be303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 20:57:58 -0600 Subject: [PATCH 16/28] feat: changelogs --- docs/changelogs/1.15.3.md | 22 ++++++++++++++++++++++ package.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/changelogs/1.15.3.md diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md new file mode 100644 index 000000000..0b01c692b --- /dev/null +++ b/docs/changelogs/1.15.3.md @@ -0,0 +1,22 @@ +# Blitzkrieg 1.15.3 + +The bot now gets more expressive! + +## Features + +- The bot can now have presence messages; examples: + - "Living in servers" + - "Server users" + - "Observing channels" + - More will be added in the future! Give me some ideas + +## Changes + +- Moved `/credits` to `/about creators` +- `/debug` command now ditches embeds and has better information to serve + +## Technical Changes + +- Removed manual trigger for Asian latest ratings leaderboard archiver +- Leaderboard archiver now accepts an explicit target like `midnight` or `latest` +- Combined midnight and latest leaderboard archival workflow into one file diff --git a/package.json b/package.json index 7342591a2..4b549bce7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.2", + "version": "1.15.3", "description": "๐ŸŽ‰ Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", From 750e145f0389059d012a4bf581602c8f65828933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:03:29 -0600 Subject: [PATCH 17/28] feat: version lint --- .github/workflows/cd-version.yml | 32 ++++++++++++++++++++++++++++++++ docs/changelogs/1.15.3.md | 4 ++++ package.json | 1 + scripts/checkVersionMissMatch.ts | 12 ++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 .github/workflows/cd-version.yml create mode 100644 scripts/checkVersionMissMatch.ts diff --git a/.github/workflows/cd-version.yml b/.github/workflows/cd-version.yml new file mode 100644 index 000000000..db7935531 --- /dev/null +++ b/.github/workflows/cd-version.yml @@ -0,0 +1,32 @@ +name: CD Version + +on: [push, pull_request] + +jobs: + host: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install Yarn + run: npm install --location=global yarn + + - name: Use node_modules cache + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn + + - name: Generate leaderboard + run: yarn lint:version diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index 0b01c692b..c85cc7bf8 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -15,6 +15,10 @@ The bot now gets more expressive! - Moved `/credits` to `/about creators` - `/debug` command now ditches embeds and has better information to serve +## Technical Features + +- Added a workflow and lint for package and changelog version miss match + ## Technical Changes - Removed manual trigger for Asian latest ratings leaderboard archiver diff --git a/package.json b/package.json index 4b549bce7..d9c1af04f 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "npx tsc", "lint:website": "next lint", "format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"", + "lint:version": "vite-node --script scripts/checkVersionMissMatch", "knip": "knip", "update": "yarn upgrade --latest" }, diff --git a/scripts/checkVersionMissMatch.ts b/scripts/checkVersionMissMatch.ts new file mode 100644 index 000000000..a13c9351e --- /dev/null +++ b/scripts/checkVersionMissMatch.ts @@ -0,0 +1,12 @@ +import { readdir } from 'fs/promises'; +import packageJSON from '../package.json'; + +const { version } = packageJSON; +const changelogs = await readdir('docs/changelogs'); +const hasVersion = changelogs.includes(`${version}.md`); + +if (hasVersion) { + console.log(`Version ${version} found in changelogs`); +} else { + throw new Error(`Version ${version} not found in changelogs`); +} From 222fa89422f048be8e2c90b77544d84c74932664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:04:04 -0600 Subject: [PATCH 18/28] fix: remove pull request --- .github/workflows/cd-version.yml | 2 +- .github/workflows/ci-build-bot.yml | 2 +- .github/workflows/ci-build-docs.yml | 2 +- .github/workflows/ci-build-website.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd-version.yml b/.github/workflows/cd-version.yml index db7935531..33813f6e2 100644 --- a/.github/workflows/cd-version.yml +++ b/.github/workflows/cd-version.yml @@ -1,6 +1,6 @@ name: CD Version -on: [push, pull_request] +on: [push] jobs: host: diff --git a/.github/workflows/ci-build-bot.yml b/.github/workflows/ci-build-bot.yml index 1a3f05e23..2a4c43690 100644 --- a/.github/workflows/ci-build-bot.yml +++ b/.github/workflows/ci-build-bot.yml @@ -1,6 +1,6 @@ name: CI Build Bot -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-docs.yml b/.github/workflows/ci-build-docs.yml index 79c7c3095..8f083841a 100644 --- a/.github/workflows/ci-build-docs.yml +++ b/.github/workflows/ci-build-docs.yml @@ -1,6 +1,6 @@ name: CI Build Docs -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-website.yml b/.github/workflows/ci-build-website.yml index 4f48e8b62..5a2b81c9e 100644 --- a/.github/workflows/ci-build-website.yml +++ b/.github/workflows/ci-build-website.yml @@ -1,6 +1,6 @@ name: CI Build Website -on: [push, pull_request] +on: [push] concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 25e1f4caa449284c4565ef91266637898a5e58fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:09:24 -0600 Subject: [PATCH 19/28] fix: workflow triggers --- .github/workflows/cd-docs.yml | 2 +- .github/workflows/ci-build-bot.yml | 2 +- .github/workflows/ci-build-docs.yml | 2 +- .github/workflows/ci-build-website.yml | 2 +- .github/workflows/{cd-version.yml => ci-version.yml} | 4 ++-- docs/changelogs/1.15.3.md | 4 ++++ 6 files changed, 10 insertions(+), 6 deletions(-) rename .github/workflows/{cd-version.yml => ci-version.yml} (95%) diff --git a/.github/workflows/cd-docs.yml b/.github/workflows/cd-docs.yml index 61855855e..74d93ec97 100644 --- a/.github/workflows/cd-docs.yml +++ b/.github/workflows/cd-docs.yml @@ -2,7 +2,7 @@ name: CD Docs on: push: - branches: [main] + branches: main jobs: build: diff --git a/.github/workflows/ci-build-bot.yml b/.github/workflows/ci-build-bot.yml index 2a4c43690..2f29938cb 100644 --- a/.github/workflows/ci-build-bot.yml +++ b/.github/workflows/ci-build-bot.yml @@ -1,6 +1,6 @@ name: CI Build Bot -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-docs.yml b/.github/workflows/ci-build-docs.yml index 8f083841a..c9dfbaca0 100644 --- a/.github/workflows/ci-build-docs.yml +++ b/.github/workflows/ci-build-docs.yml @@ -1,6 +1,6 @@ name: CI Build Docs -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci-build-website.yml b/.github/workflows/ci-build-website.yml index 5a2b81c9e..66c3eb778 100644 --- a/.github/workflows/ci-build-website.yml +++ b/.github/workflows/ci-build-website.yml @@ -1,6 +1,6 @@ name: CI Build Website -on: [push] +on: push concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/cd-version.yml b/.github/workflows/ci-version.yml similarity index 95% rename from .github/workflows/cd-version.yml rename to .github/workflows/ci-version.yml index 33813f6e2..3e567d42d 100644 --- a/.github/workflows/cd-version.yml +++ b/.github/workflows/ci-version.yml @@ -1,6 +1,6 @@ -name: CD Version +name: CI Version -on: [push] +on: push jobs: host: diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index c85cc7bf8..a10364bdf 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -24,3 +24,7 @@ The bot now gets more expressive! - Removed manual trigger for Asian latest ratings leaderboard archiver - Leaderboard archiver now accepts an explicit target like `midnight` or `latest` - Combined midnight and latest leaderboard archival workflow into one file + +## Technical Fixed + +- Reviewed all workflow triggers and updated them From 10f64902aaca32868265aab7e304d1c3353a0038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sat, 25 Nov 2023 21:10:53 -0600 Subject: [PATCH 20/28] fix: xml in md --- docs/changelogs/1.15.3.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/changelogs/1.15.3.md b/docs/changelogs/1.15.3.md index a10364bdf..8772fc54a 100644 --- a/docs/changelogs/1.15.3.md +++ b/docs/changelogs/1.15.3.md @@ -5,9 +5,9 @@ The bot now gets more expressive! ## Features - The bot can now have presence messages; examples: - - "Living in servers" - - "Server users" - - "Observing channels" + - "Living in {number} servers" + - "Server {number} users" + - "Observing {number} channels" - More will be added in the future! Give me some ideas ## Changes From 1a66cab4357516b21af3cc95cbf3f427ab88c52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 11:59:02 -0600 Subject: [PATCH 21/28] feat: change name to have "Ratings" in the front --- .github/workflows/cd-ratings-asia.yml | 2 +- .github/workflows/cd-ratings-eu.yml | 2 +- .github/workflows/cd-ratings-na.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd-ratings-asia.yml b/.github/workflows/cd-ratings-asia.yml index 6135fc719..1c237bcb2 100644 --- a/.github/workflows/cd-ratings-asia.yml +++ b/.github/workflows/cd-ratings-asia.yml @@ -1,4 +1,4 @@ -name: CD Asia Ratings +name: CD Ratings Asia # latest: '0 0 * * *' # asia midnight: '0 17 * * *' diff --git a/.github/workflows/cd-ratings-eu.yml b/.github/workflows/cd-ratings-eu.yml index b0f0d0a78..1f699cfa4 100644 --- a/.github/workflows/cd-ratings-eu.yml +++ b/.github/workflows/cd-ratings-eu.yml @@ -1,4 +1,4 @@ -name: CD Europe Ratings +name: CD Ratings Europe # latest: '0 0 * * *' # eu midnight: '0 23 * * *' diff --git a/.github/workflows/cd-ratings-na.yml b/.github/workflows/cd-ratings-na.yml index 8c91f1600..89b801ce0 100644 --- a/.github/workflows/cd-ratings-na.yml +++ b/.github/workflows/cd-ratings-na.yml @@ -1,4 +1,4 @@ -name: CD North America Ratings +name: CD Ratings North America # latest: '0 0 * * *' # na midnight: '0 5 * * *' From 338a2a14bf1a56eb823ff3754cef98c280dfd522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:00:19 -0600 Subject: [PATCH 22/28] fix: continue after no player found --- scripts/buildRatingsLeaderboard.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index a84929c02..d6ec1ba1f 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -101,7 +101,10 @@ await Promise.all([ console.log('Converting to an array...'); for (let index = 0; index < PLAYERS; index++) { const listing = players[index + 1]; - if (!listing) console.warn(`Position ${index + 1} had no player`); + if (!listing) { + console.warn(`Position ${index + 1} had no player`); + continue; + } leaderboard[index] = { id: listing.spa_id, From aae26523ffb7afe41ef08fe4f65a3dccbb8a4fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:01:32 -0600 Subject: [PATCH 23/28] feat: renamed blitzkrieg-db to blitzkrieg-assets --- scripts/buildRatingsLeaderboard.ts | 2 +- src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts | 2 +- src/core/blitzkrieg/getArchivedRatingsInfo.ts | 2 +- src/core/blitzkrieg/getArchivedRatingsLeaderboard.ts | 2 +- src/core/blitzkrieg/getArchivedRatingsMidnightLeaderboard.ts | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index d6ec1ba1f..fe27a6ac2 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -130,7 +130,7 @@ if (publish) { commitMultipleFiles( octokit, 'tresabhi', - 'blitzkrieg-db', + 'blitzkrieg-assets', 'main', new Date().toString(), [ diff --git a/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts b/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts index 8d508e0e1..d5688089f 100644 --- a/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts +++ b/src/core/blitzkrieg/getArchivedLatestSeasonNumber.ts @@ -8,7 +8,7 @@ export async function getArchivedLatestSeasonNumber() { if (ratingsInfo.detail) { const comURL = ( (await fetch( - 'https://api.github.com/repos/tresabhi/blitzkrieg-db/git/trees/main', + 'https://api.github.com/repos/tresabhi/blitzkrieg-assets/git/trees/main', ).then((response) => response.json())) as { tree: { path: string; url: string }[]; } diff --git a/src/core/blitzkrieg/getArchivedRatingsInfo.ts b/src/core/blitzkrieg/getArchivedRatingsInfo.ts index e08b9793a..a69af3b7d 100644 --- a/src/core/blitzkrieg/getArchivedRatingsInfo.ts +++ b/src/core/blitzkrieg/getArchivedRatingsInfo.ts @@ -24,7 +24,7 @@ export default async function getArchivedRatingsInfo( } const response = await fetch( - `https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/info.json`, + `https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/info.json`, ); const jsonContent = (await response.json()) as RatingsInfo & { detail: undefined; diff --git a/src/core/blitzkrieg/getArchivedRatingsLeaderboard.ts b/src/core/blitzkrieg/getArchivedRatingsLeaderboard.ts index 29e59e56e..f116ea00f 100644 --- a/src/core/blitzkrieg/getArchivedRatingsLeaderboard.ts +++ b/src/core/blitzkrieg/getArchivedRatingsLeaderboard.ts @@ -19,7 +19,7 @@ export async function getArchivedRatingsLeaderboard( } const response = await fetch( - `https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/latest.json`, + `https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/latest.json`, ); const json = (await response.json()) as BlitzkriegRatingsLeaderboard; LEADERBOARD_CACHE[region][season] = json; diff --git a/src/core/blitzkrieg/getArchivedRatingsMidnightLeaderboard.ts b/src/core/blitzkrieg/getArchivedRatingsMidnightLeaderboard.ts index 85c7029b0..f656d23c0 100644 --- a/src/core/blitzkrieg/getArchivedRatingsMidnightLeaderboard.ts +++ b/src/core/blitzkrieg/getArchivedRatingsMidnightLeaderboard.ts @@ -1,7 +1,7 @@ import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard'; import { Region } from '../../constants/regions'; -export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' }; +export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-assets' }; const MIDNIGHT_LEADERBOARD_CACHE: Record< Region, @@ -22,7 +22,7 @@ export default async function getArchivedRatingsMidnightLeaderboard( try { const response = await fetch( - `https://raw.githubusercontent.com/tresabhi/blitzkrieg-db/main/${region}/ratings/${season}/midnight.json`, + `https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/midnight.json`, ); const json = (await response.json()) as BlitzkriegRatingsLeaderboard; MIDNIGHT_LEADERBOARD_CACHE[region][season] = json; From 9d3d74c7c5e9992808242f5a11e7d83624c26885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:03:17 -0600 Subject: [PATCH 24/28] feat: change ratings root dir to "ratings" --- scripts/buildRatingsLeaderboard.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/buildRatingsLeaderboard.ts b/scripts/buildRatingsLeaderboard.ts index fe27a6ac2..cedf7e465 100644 --- a/scripts/buildRatingsLeaderboard.ts +++ b/scripts/buildRatingsLeaderboard.ts @@ -116,14 +116,12 @@ const leaderboardJSON = JSON.stringify(leaderboard); if (publish) { const octokit = new Octokit({ auth: env.GH_TOKEN }); - const info = await patientFetchJSON( `https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`, ); const normalizedServer = server === 'na' ? 'com' : server; - - const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`; - const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${target}.json`; + const infoPath = `regions/${normalizedServer}/ratings/${info.current_season}/info.json`; + const leaderboardPath = `regions/${normalizedServer}/ratings/${info.current_season}/${target}.json`; const infoJSON = JSON.stringify(info); console.log(`Publishing to season ${info.current_season}...`); From ba9f593716b242bb6569b2ba8cb17f17f5d1f3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:06:00 -0600 Subject: [PATCH 25/28] feat: changelogs --- docs/changelogs/1.15.4.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/changelogs/1.15.4.md diff --git a/docs/changelogs/1.15.4.md b/docs/changelogs/1.15.4.md new file mode 100644 index 000000000..b1bfa06dd --- /dev/null +++ b/docs/changelogs/1.15.4.md @@ -0,0 +1,13 @@ +# Blitzkrieg 1.15.4 + +Unlocking future potential + +## Technical Changes + +- Moved the word "Ratings" to the front of the workflow name +- Renamed `blitzkrieg-db` to `blitzkrieg-assets` +- Moved the region folders from the root to `regions` + +## Technical Fixes + +- The ratings leaderboard archiver now correctly skips undefined players From 5ca64f839e9d99f3206d67f52e28e0c4351f0132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:12:57 -0600 Subject: [PATCH 26/28] fix: exhaustive user and channel indexing --- src/events/ready.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/events/ready.ts b/src/events/ready.ts index d63ceeb31..a6278013e 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -5,8 +5,17 @@ export default function ready(client: Client) { const activities: (() => string)[] = [ () => `Living in ${client.guilds.cache.size.toLocaleString()} servers`, - () => `Serving ${client.users.cache.size.toLocaleString()} users`, - () => `Observing ${client.channels.cache.size.toLocaleString()} channels`, + () => + `Serving ${client.guilds.cache + .reduce((accumulator, guild) => accumulator + guild.memberCount, 0) + .toLocaleString()} users`, + () => + `Observing ${client.guilds.cache + .reduce( + (accumulator, guild) => accumulator + guild.channels.cache.size, + 0, + ) + .toLocaleString()} channels`, ]; client.user.setPresence({ From d1d9e9e4d1f33e14930d27b9e03751eabb7a0a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:14:35 -0600 Subject: [PATCH 27/28] feat: changelogs --- docs/changelogs/1.15.5.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 docs/changelogs/1.15.5.md diff --git a/docs/changelogs/1.15.5.md b/docs/changelogs/1.15.5.md new file mode 100644 index 000000000..331b343a2 --- /dev/null +++ b/docs/changelogs/1.15.5.md @@ -0,0 +1,7 @@ +# Blitzkrieg 1.15.4 + +Oops, this should've been in the last patch. + +## Fixes + +- User and channel cache is now guild cache exhaustive diff --git a/package.json b/package.json index d9c1af04f..58a4cf0c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.15.3", + "version": "1.15.5", "description": "๐ŸŽ‰ Tools for everything World of Tanks Blitz", "main": "src/server.ts", "type": "module", From 54c5faf92923a1a1db2bff824fb0427e196384f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:15:24 -0600 Subject: [PATCH 28/28] fix: changelog version --- docs/changelogs/1.15.5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelogs/1.15.5.md b/docs/changelogs/1.15.5.md index 331b343a2..439b14476 100644 --- a/docs/changelogs/1.15.5.md +++ b/docs/changelogs/1.15.5.md @@ -1,4 +1,4 @@ -# Blitzkrieg 1.15.4 +# Blitzkrieg 1.15.5 Oops, this should've been in the last patch.