Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't add to kv for new events
  • Loading branch information
regalijan committed Feb 14, 2024
1 parent bf6fdc7 commit 4ba23c2
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions functions/api/events-team/events/new.ts
Expand Up @@ -62,9 +62,10 @@ export async function onRequestPost(context: RequestContext) {
const id = `${now.getTime()}${crypto.randomUUID().replaceAll("-", "")}`;

await context.env.D1.prepare(
"INSERT INTO events (created_at, created_by, day, id, month, type, year) VALUES (?, ?, ?, ?, ?, ?, ?);",
"INSERT INTO events (answer, created_at, created_by, day, id, month, type, year) VALUES (?, ?, ?, ?, ?, ?, ?);",
)
.bind(
context.data.body.answer || null,
now.getTime(),
context.data.current_user.id,
day,
Expand All @@ -75,23 +76,6 @@ export async function onRequestPost(context: RequestContext) {
)
.run();

await context.env.DATA.put(
`event_${id}`,
JSON.stringify({
answer: context.data.body.answer,
created_at: now.getTime(),
created_by: context.data.current_user.id,
day,
details,
month: currentMonth,
pending: true,
year: currentYear,
}),
{
expirationTtl: 15552000,
},
);

return new Response(null, {
status: 204,
});
Expand Down

0 comments on commit 4ba23c2

Please sign in to comment.