From 4e0f0536fa769f9f509652699e8a59825511f44c Mon Sep 17 00:00:00 2001 From: tresabhi Date: Fri, 14 Jul 2023 17:27:57 +0000 Subject: [PATCH] feat: added separate latest and leaderboards for all regions --- .github/workflows/cd-asia-ratings-latest.yml | 34 +++++++++++++++++++ .../cd-asia-ratings-leaderboards.yml | 34 +++++++++++++++++++ .github/workflows/cd-eu-ratings-latest.yml | 34 +++++++++++++++++++ .../workflows/cd-eu-ratings-leaderboards.yml | 34 +++++++++++++++++++ .github/workflows/cd-na-ratings-latest.yml | 34 +++++++++++++++++++ ...-na.yml => cd-na-ratings-leaderboards.yml} | 2 +- scripts/generateRatingsLeaderboard.js | 19 +++++++---- 7 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/cd-asia-ratings-latest.yml create mode 100644 .github/workflows/cd-asia-ratings-leaderboards.yml create mode 100644 .github/workflows/cd-eu-ratings-latest.yml create mode 100644 .github/workflows/cd-eu-ratings-leaderboards.yml create mode 100644 .github/workflows/cd-na-ratings-latest.yml rename .github/workflows/{cd-ratings-leaderboard-na.yml => cd-na-ratings-leaderboards.yml} (94%) diff --git a/.github/workflows/cd-asia-ratings-latest.yml b/.github/workflows/cd-asia-ratings-latest.yml new file mode 100644 index 000000000..e1ebeae35 --- /dev/null +++ b/.github/workflows/cd-asia-ratings-latest.yml @@ -0,0 +1,34 @@ +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=asia --latest diff --git a/.github/workflows/cd-asia-ratings-leaderboards.yml b/.github/workflows/cd-asia-ratings-leaderboards.yml new file mode 100644 index 000000000..a36164a29 --- /dev/null +++ b/.github/workflows/cd-asia-ratings-leaderboards.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Leaderboards + +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=asia diff --git a/.github/workflows/cd-eu-ratings-latest.yml b/.github/workflows/cd-eu-ratings-latest.yml new file mode 100644 index 000000000..62171b2a9 --- /dev/null +++ b/.github/workflows/cd-eu-ratings-latest.yml @@ -0,0 +1,34 @@ +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=eu --latest diff --git a/.github/workflows/cd-eu-ratings-leaderboards.yml b/.github/workflows/cd-eu-ratings-leaderboards.yml new file mode 100644 index 000000000..ffab76388 --- /dev/null +++ b/.github/workflows/cd-eu-ratings-leaderboards.yml @@ -0,0 +1,34 @@ +name: CD North America Ratings Leaderboards + +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=eu diff --git a/.github/workflows/cd-na-ratings-latest.yml b/.github/workflows/cd-na-ratings-latest.yml new file mode 100644 index 000000000..ff7ab3470 --- /dev/null +++ b/.github/workflows/cd-na-ratings-latest.yml @@ -0,0 +1,34 @@ +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 --latest diff --git a/.github/workflows/cd-ratings-leaderboard-na.yml b/.github/workflows/cd-na-ratings-leaderboards.yml similarity index 94% rename from .github/workflows/cd-ratings-leaderboard-na.yml rename to .github/workflows/cd-na-ratings-leaderboards.yml index 32a3c2c7e..414e143a3 100644 --- a/.github/workflows/cd-ratings-leaderboard-na.yml +++ b/.github/workflows/cd-na-ratings-leaderboards.yml @@ -1,4 +1,4 @@ -name: CD Ratings Leaderboard North America +name: CD North America Ratings Leaderboards on: schedule: diff --git a/scripts/generateRatingsLeaderboard.js b/scripts/generateRatingsLeaderboard.js index e1d4c59c1..b39f732dd 100644 --- a/scripts/generateRatingsLeaderboard.js +++ b/scripts/generateRatingsLeaderboard.js @@ -4,12 +4,17 @@ import { argv, env } from 'process'; import commitMultipleFiles from './commitMultipleFiles.js'; /* -For Central North American Time (UTC-5), use 0 5 * * *. -For Central European Time (UTC+1), use 0 23 * * *. -For Central Asia Standard Time (UTC+7), use 0 17 * * *. -*/ + * Central North American Time (UTC-5): use 0 5 * * *. + * Central European Time (UTC+1): use 0 23 * * *. + * Central Asia Standard Time (UTC+7): use 0 17 * * *. + * + * :region/ratings/:season/info.json: season info like rewards, start & end time, etc. + * :region/ratings/:season/latest.json: the absolute latest leaderboard recorded at UTC+0 midnight + * :region/ratings/:season/leaderboards/:time.json: collection of all recorded leaderboards at local midnights + */ const publish = argv.includes('--publish'); +const latest = argv.includes('--latest'); const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1]; if (!server) throw new Error('Region parameter not specified'); @@ -96,8 +101,10 @@ if (publish) { const time = Math.round(Date.now() / 1000); const normalizedServer = server === 'na' ? 'com' : server; - const infoPath = `${normalizedServer}/ratings/seasons/${info.current_season}.json`; - const leaderboardPath = `${normalizedServer}/ratings/leaderboards/${info.current_season}/${time}.json`; + const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`; + const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${ + latest ? 'latest.json' : `leaderboards/${time}.json` + }`; const infoJSON = JSON.stringify(info); console.log(`Publishing to season ${info.current_season}...`);