fix(02): populate hasRrule on every sync upsert so recurring masters are flagged
- Use ICAL.Event.isRecurring() (parity with expand.ts) to detect RRULE/RDATE - Add hasRrule to .values() INSERT and .onDuplicateKeyUpdate() SET so the flag is set on first sync and self-heals on every subsequent re-sync - Without this fix every event had has_rrule=0 (column default), causing the events route recurring-master pre-filter to return zero recurring occurrences - Add sync.test.ts cases: hasRrule=true for timed+all-day recurring VEVENTs, hasRrule=false for non-recurring, and hasRrule in onDuplicateKeyUpdate.set
This commit is contained in:
@@ -89,6 +89,10 @@ export async function syncCalendar(
|
||||
// D-13 / Pitfall #3: isDate=true → DATE column; isDate=false → TIMESTAMP column
|
||||
const allDay: boolean = dtstart?.isDate ?? false
|
||||
|
||||
// Determine if this event is a recurring master (has RRULE or RDATE).
|
||||
// Use ICAL.Event.isRecurring() for parity with expand.ts — it checks both properties.
|
||||
const isRecurring: boolean = new ICAL.Event(vevent).isRecurring()
|
||||
|
||||
// dtstartDate: Drizzle's `date` column accepts a Date object or null.
|
||||
// We convert the YYYY-MM-DD string from ical.js to a Date (at midnight UTC) so
|
||||
// Drizzle serialises it correctly as a DATE without a time component.
|
||||
@@ -106,6 +110,7 @@ export async function syncCalendar(
|
||||
dtstartUtc: dtstartUtcValue,
|
||||
dtstartDate: dtstartDateValue,
|
||||
allDay,
|
||||
hasRrule: isRecurring,
|
||||
})
|
||||
.onDuplicateKeyUpdate({
|
||||
set: {
|
||||
@@ -114,6 +119,7 @@ export async function syncCalendar(
|
||||
dtstartUtc: dtstartUtcValue,
|
||||
dtstartDate: dtstartDateValue,
|
||||
allDay,
|
||||
hasRrule: isRecurring,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user