diff --git a/apps/charity/pages/api/cron/reward-leaderboards-daily.ts b/apps/charity/pages/api/cron/reward-leaderboards-daily.ts deleted file mode 100644 index d325481c..00000000 --- a/apps/charity/pages/api/cron/reward-leaderboards-daily.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { prisma } from '@worksheets/prisma'; -import { rewardTopPlayers } from '@worksheets/services/leaderboards'; -import { createCronJob } from '@worksheets/util/cron'; - -export default createCronJob(async () => { - await rewardTopPlayers(prisma, 'DAILY'); -}); diff --git a/libs/services/leaderboards/src/util.test.ts b/libs/services/leaderboards/src/util.test.ts index 4f81d10d..79db6742 100644 --- a/libs/services/leaderboards/src/util.test.ts +++ b/libs/services/leaderboards/src/util.test.ts @@ -3,12 +3,6 @@ import { LeaderboardFrequency } from '@worksheets/util/types'; import { getPayoutDates } from './util'; describe('getPayoutDates', () => { it.each([ - [ - 'DAILY', - new Date('2021-01-01T00:00:00Z'), - new Date('2020-12-31T00:00:00Z'), - new Date('2020-12-31T23:59:59.999Z'), - ], [ 'WEEKLY', new Date('2021-01-01T00:00:00Z'), diff --git a/libs/services/leaderboards/src/util.ts b/libs/services/leaderboards/src/util.ts index d89b0469..474007a1 100644 --- a/libs/services/leaderboards/src/util.ts +++ b/libs/services/leaderboards/src/util.ts @@ -6,36 +6,6 @@ export const getPayoutDates = ( frequency: LeaderboardFrequency, now: Date = new Date() ) => { - if (frequency === 'DAILY') { - const yesterday = new Date(now); - yesterday.setUTCDate(yesterday.getUTCDate() - 1); - - const starting = new Date( - Date.UTC( - yesterday.getUTCFullYear(), - yesterday.getUTCMonth(), - yesterday.getUTCDate(), - 0, - 0, - 0, - 0 - ) - ); - const ending = new Date( - Date.UTC( - yesterday.getUTCFullYear(), - yesterday.getUTCMonth(), - yesterday.getUTCDate(), - 23, - 59, - 59, - 999 - ) - ); - - return { starting, ending }; - } - if (frequency === 'WEEKLY') { // Find the Sunday of the week before the last const start = new Date(now); diff --git a/libs/ui/pages/game/src/lib/components/game-leaderboards/game-leaderboards.tsx b/libs/ui/pages/game/src/lib/components/game-leaderboards/game-leaderboards.tsx index 0ced1411..0200e86b 100644 --- a/libs/ui/pages/game/src/lib/components/game-leaderboards/game-leaderboards.tsx +++ b/libs/ui/pages/game/src/lib/components/game-leaderboards/game-leaderboards.tsx @@ -8,10 +8,8 @@ import { nth } from '@worksheets/util/numbers'; import { durationToString, lastSundayUtcMidnight, - lastUtcMidnight, millisecondsAsDuration, nextSundayUtcMidnight, - nextUtcMidnight, printDateTime, } from '@worksheets/util/time'; import { NO_REFETCH } from '@worksheets/util/trpc'; @@ -30,7 +28,7 @@ import { LeaderboardTable } from './leaderboard-table'; export const GameLeaderboards: FC<{ gameId: string; }> = ({ gameId }) => { - const [frequency, setFrequency] = useState('DAILY'); + const [frequency, setFrequency] = useState('WEEKLY'); return ( { - if (frequency === 'DAILY') { - return { - start: lastUtcMidnight(), - end: nextUtcMidnight(), - }; - } - if (frequency === 'WEEKLY') { return { start: lastSundayUtcMidnight(), diff --git a/libs/util/types/src/lib/leaderboards.ts b/libs/util/types/src/lib/leaderboards.ts index dfb3c2c2..07f0dd70 100644 --- a/libs/util/types/src/lib/leaderboards.ts +++ b/libs/util/types/src/lib/leaderboards.ts @@ -1,11 +1,10 @@ import { assertNever } from '@worksheets/util/errors'; -import { lastSundayUtcMidnight, lastUtcMidnight } from '@worksheets/util/time'; +import { lastSundayUtcMidnight } from '@worksheets/util/time'; import { z } from 'zod'; -export const LEADERBOARD_LIMIT = 16; +export const LEADERBOARD_LIMIT = 32; export const LEADERBOARD_FREQUENCY = { - DAILY: 'DAILY', WEEKLY: 'WEEKLY', ALL_TIME: 'ALL_TIME', } as const; @@ -14,7 +13,6 @@ export const LEADERBOARD_FREQUENCY_LABELS: Record< LeaderboardFrequency, string > = { - DAILY: 'Daily', WEEKLY: 'Weekly', ALL_TIME: 'All Time', }; @@ -25,7 +23,6 @@ export type LeaderboardFrequency = keyof typeof LEADERBOARD_FREQUENCY; export const LEADERBOARD_REWARD_PAYOUT: Record = { - DAILY: [150, 75, 50, 50, 25, 25], WEEKLY: [400, 300, 150, 150, 100, 100, 50, 50, 25, 25], ALL_TIME: [], }; @@ -44,10 +41,6 @@ export type LeaderboardPlayerSchema = z.infer; export const getLeaderboardFrequencyDate = ( frequency: LeaderboardFrequency ): Date => { - if (frequency === 'DAILY') { - return lastUtcMidnight(); - } - if (frequency === 'WEEKLY') { return lastSundayUtcMidnight(); } diff --git a/vercel.json b/vercel.json index 7332d783..cf93fc7d 100644 --- a/vercel.json +++ b/vercel.json @@ -52,10 +52,6 @@ "path": "/api/cron/spawn-raffle", "schedule": "0 0 * * *" }, - { - "path": "/api/cron/reward-leaderboards-daily", - "schedule": "0 0 * * *" - }, { "path": "/api/cron/reward-leaderboards-weekly", "schedule": "0 0 * * 0"