Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove speculative point double counting
  • Loading branch information
regalijan committed Feb 10, 2025
1 parent 17e0cdf commit 3902809
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions app/routes/et-members.tsx
Expand Up @@ -51,32 +51,7 @@ export async function loader({ context }: { context: RequestContext }) {
status: 500,
});

const now = new Date();
const members = etData.results as { [k: string]: any }[];
const currentMonthEvents = await context.env.D1.prepare(
"SELECT answered_at, created_by, performed_at, reached_minimum_player_count, type FROM events WHERE year = ? AND month = ?;",
)
.bind(now.getUTCFullYear(), now.getUTCMonth() + 1)
.all();

if (!currentMonthEvents.error) {
for (const event of currentMonthEvents.results as { [k: string]: any }[]) {
const memberIdx = members.findIndex((m) => m.id === event.created_by);

if (memberIdx === -1) continue;

if (event.performed_at) members[memberIdx].points += 10;
if (event.type === "gamenight" && event.reached_minimum_player_count)
members[memberIdx].points += 10;
if (
event.type === "rotw" &&
event.answered_at - event.performed_at >= 86400000
)
members[memberIdx].points += 10;
if (!event.performed_at && event.day < now.getUTCDate())
members[memberIdx].points -= 5;
}
}

return { members } as {
members: { [k: string]: any }[];
Expand Down

0 comments on commit 3902809

Please sign in to comment.