Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix existing event check
  • Loading branch information
regalijan committed Feb 28, 2024
1 parent 1768328 commit a4d21f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions functions/api/events-team/events/new.ts
Expand Up @@ -23,7 +23,7 @@ export async function onRequestPost(context: RequestContext) {

if (
await context.env.D1.prepare(
"SELECT * FROM events WHERE (approved = true OR approved IS NULL) AND day = ? AND month = ? AND type = ? AND year = ?;",
"SELECT * FROM events WHERE (approved = 1 OR pending =1) AND day = ? AND month = ? AND type = ? AND year = ?;",
)
.bind(day, currentMonth, type, currentYear)
.first()
Expand All @@ -45,7 +45,7 @@ export async function onRequestPost(context: RequestContext) {
const weekRange = Math.floor(day / 7);

const existingEventInRange = await context.env.D1.prepare(
"SELECT id FROM events WHERE (approved = true OR approved IS NULL) AND day > ? AND day <= ? AND month = ? AND type = 'rotw' AND year = ?;",
"SELECT id FROM events WHERE (approved = 1 OR pending = 1) AND day BETWEEN ? AND ? AND month = ? AND type = 'rotw' AND year = ?;",
)
.bind(
weekRanges[weekRange] - 7,
Expand Down

0 comments on commit a4d21f4

Please sign in to comment.