From eb00ec7dfb921a657facc617ac75480a37b7bcb6 Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Wed, 10 Jun 2026 16:51:19 -0400 Subject: [PATCH] fix(06): WR-01 gate all-day SQL branch on hasRrule=0 to stop duplicate occurrences --- apps/api/src/routes/events.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/events.ts b/apps/api/src/routes/events.ts index c57558e..0f70397 100644 --- a/apps/api/src/routes/events.ts +++ b/apps/api/src/routes/events.ts @@ -198,8 +198,13 @@ eventsRouter.get('/', zValidator('query', eventsQuerySchema), async (c) => { sql`${calendarEvents.dtstartUtc} >= ${windowStartDate}`, sql`${calendarEvents.dtstartUtc} < ${windowEndDate}`, ), - // All-day events: dtstartDate falls in [start, end) — DATE comparison, no time component + // Non-recurring all-day events: dtstartDate falls in [start, end) — DATE comparison. + // WR-01: gate on hasRrule = 0 so a recurring all-day master whose dtstartDate + // lands in the window is NOT also matched here (it is already carried by the + // recurring branch above). Without this gate the master is expanded twice and + // every occurrence is duplicated on the wire. and( + sql`${calendarEvents.hasRrule} = 0`, sql`${calendarEvents.dtstartDate} IS NOT NULL`, sql`${calendarEvents.dtstartDate} >= ${start}`, sql`${calendarEvents.dtstartDate} < ${end}`,