diff --git a/.github/workflows/cd-averages.yml b/.github/workflows/cd-averages.yml new file mode 100644 index 000000000..12a362f67 --- /dev/null +++ b/.github/workflows/cd-averages.yml @@ -0,0 +1,33 @@ +name: CD Averages + +on: + push: + branches: dev + workflow_dispatch: + schedule: + - cron: '0 12 * * 0' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v1 + + - name: Install dependencies + run: bun install + + - name: Build averages + run: | + GH_TOKEN=${{ secrets.GH_TOKEN }} + DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} + DATABASE_URL=${{ secrets.DATABASE_URL }} + VIDEOS_SHEET=${{ secrets.VIDEOS_SHEET }} + GOOGLE_APPLICATION_CREDENTIALS=${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + bun scripts/averages.ts diff --git a/scripts/averages.ts b/scripts/averages.ts index 7e931a805..82b240768 100644 --- a/scripts/averages.ts +++ b/scripts/averages.ts @@ -16,7 +16,7 @@ import { superCompress } from '../src/core/blitzkit/superCompress'; import { DidsReadStream, DidsWriteStream } from '../src/core/streams/dids'; import { IndividualTankStats } from '../src/types/tanksStats'; -const RUN_TIME = 1000 * 0; +const RUN_TIME = 1000 * 60 * 60; const MAX_REQUESTS = 10; const production = argv.includes('--production'); @@ -124,7 +124,9 @@ function discover() { discoveredIds.push(id); players.push(stats); - console.log(`discovered ${id} in ${region}`); + console.log( + `discovered ${id} in ${region} (time left: ${RUN_TIME - (Date.now() - startTime)}ms)`, + ); } setTimeout(chainDiscovery); // circumvent max call stack