More events team nonsense
All checks were successful
Test, Build, Deploy / Test, Build, and Deploy (push) Successful in 55s
Test, Build, Deploy / Create Sentry Release (push) Successful in 6s

This commit is contained in:
2026-04-11 03:30:46 -04:00
parent 465bb30966
commit cfc57c838e
17 changed files with 355 additions and 259 deletions

View File

@@ -2,22 +2,25 @@ import { jsonError } from "../../../../common.js";
export async function onRequestPost(context: RequestContext) {
const { D1 } = context.env;
const { event } = context.data;
const { event, prisma } = context.data;
try {
const row = await D1.prepare(
"SELECT performed_at FROM events WHERE id = ?;",
)
.bind(event.id)
.first();
const row = await prisma.event.findUnique({
select: {
performed_at: true,
},
where: {
id: event.id,
},
});
if (typeof row?.performed_at === "number")
if (row?.performed_at instanceof Date)
return jsonError("Event already marked as completed or forgotten", 400);
await D1.batch([
D1.prepare("UPDATE events SET performed_at = 0 WHERE id = ?;").bind(
event.id,
),
D1.prepare(
"UPDATE events SET performed_at = datetime(0, 'unixepoch') WHERE id = ?;",
).bind(event.id),
D1.prepare(
"UPDATE et_members SET points = points - 5 WHERE id = ?;",
).bind(event.created_by),