Skip to content

Commit

Permalink
leaderboards: remove daily leaderboard rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
GGonryun committed Aug 12, 2024
1 parent 92dd214 commit c7c4bd8
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 66 deletions.
7 changes: 0 additions & 7 deletions apps/charity/pages/api/cron/reward-leaderboards-daily.ts

This file was deleted.

6 changes: 0 additions & 6 deletions libs/services/leaderboards/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
30 changes: 0 additions & 30 deletions libs/services/leaderboards/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -30,7 +28,7 @@ import { LeaderboardTable } from './leaderboard-table';
export const GameLeaderboards: FC<{
gameId: string;
}> = ({ gameId }) => {
const [frequency, setFrequency] = useState<LeaderboardFrequency>('DAILY');
const [frequency, setFrequency] = useState<LeaderboardFrequency>('WEEKLY');
return (
<Box mt={2}>
<Description
Expand Down Expand Up @@ -225,13 +223,6 @@ const LeaderboardTimestamps: React.FC<{
};

const getLeaderboardTimestamps = (frequency: LeaderboardFrequency) => {
if (frequency === 'DAILY') {
return {
start: lastUtcMidnight(),
end: nextUtcMidnight(),
};
}

if (frequency === 'WEEKLY') {
return {
start: lastSundayUtcMidnight(),
Expand Down
11 changes: 2 additions & 9 deletions libs/util/types/src/lib/leaderboards.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,7 +13,6 @@ export const LEADERBOARD_FREQUENCY_LABELS: Record<
LeaderboardFrequency,
string
> = {
DAILY: 'Daily',
WEEKLY: 'Weekly',
ALL_TIME: 'All Time',
};
Expand All @@ -25,7 +23,6 @@ export type LeaderboardFrequency = keyof typeof LEADERBOARD_FREQUENCY;

export const LEADERBOARD_REWARD_PAYOUT: Record<LeaderboardFrequency, number[]> =
{
DAILY: [150, 75, 50, 50, 25, 25],
WEEKLY: [400, 300, 150, 150, 100, 100, 50, 50, 25, 25],
ALL_TIME: [],
};
Expand All @@ -44,10 +41,6 @@ export type LeaderboardPlayerSchema = z.infer<typeof leaderboardPlayerSchema>;
export const getLeaderboardFrequencyDate = (
frequency: LeaderboardFrequency
): Date => {
if (frequency === 'DAILY') {
return lastUtcMidnight();
}

if (frequency === 'WEEKLY') {
return lastSundayUtcMidnight();
}
Expand Down
4 changes: 0 additions & 4 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c7c4bd8

Please sign in to comment.