fix(06): WR-01 gate all-day SQL branch on hasRrule=0 to stop duplicate occurrences

This commit is contained in:
Lucas Berger
2026-06-10 16:51:19 -04:00
parent d101aa899d
commit eb00ec7dfb
+6 -1
View File
@@ -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}`,