All files / app-leaderboard/src index.ts

0% Statements 0/3
100% Branches 0/0
0% Functions 0/1
0% Lines 0/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                                               
import { createApp } from './app.ts';
import { bmsSearchLookup, refreshStaleChartsets } from './chartsets/refresh.ts';
import { openDatabase } from './db/client.ts';
import type { Env } from './env.ts';
import { backfillPlayedFiles } from './scores/backfill.ts';
 
export type { AppType } from './app.ts';
 
const app = createApp();
 
export default {
  fetch: app.fetch,
  /**
   * The Cron Trigger (`cloudflare.config.ts`): files charts under their chartsets and re-checks old answers, and fills
   * in the chart file and length of plays stored before those were recorded.
   */
  async scheduled(_controller, env, context) {
    const db = openDatabase(env.DB);
    context.waitUntil(
      Promise.all([refreshStaleChartsets(db, bmsSearchLookup(), Date.now()), backfillPlayedFiles(db, env.BLOBS)]),
    );
  },
} satisfies ExportedHandler<Env>;