Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

perf(ical): index recurrence exceptions by UID (#7090)

Riccardoe8318f29cec5
diff --git a/packages/integrations/src/ical/ical-integration.ts b/packages/integrations/src/ical/ical-integration.ts
index 654002f60..4d29ae9e8 100644
--- a/packages/integrations/src/ical/ical-integration.ts
+++ b/packages/integrations/src/ical/ical-integration.ts
@@ -42,11 +42,15 @@ export class ICalIntegration extends Integration implements ICalendarIntegration
const vevents = comp.getAllSubcomponents("vevent");
const masterVevents: ICAL.Component[] = [];
const exceptionVevents: ICAL.Component[] = [];
+ const exceptionVeventsByUid = new Map<string, ICAL.Component[]>();
for (const vevent of vevents) {
const event = new ICAL.Event(vevent, { exceptions: [] });
if (event.isRecurrenceException()) {
exceptionVevents.push(vevent);
+ const exceptionsForUid = exceptionVeventsByUid.get(event.uid) ?? [];
+ exceptionsForUid.push(vevent);
+ exceptionVeventsByUid.set(event.uid, exceptionsForUid);
} else {
masterVevents.push(vevent);
}
@@ -57,13 +61,10 @@ export class ICalIntegration extends Integration implements ICalendarIntegration
const emittedExceptionComponents = new Set<ICAL.Component>();
for (const masterVevent of masterVevents) {
- // exceptions: [] so an unrelated series sharing no uid is never auto-attached; uids are matched by hand below.
+ // exceptions: [] so unrelated series are never auto-attached; only matching uid buckets are related below.
const event = new ICAL.Event(masterVevent, { exceptions: [] });
- for (const exceptionVevent of exceptionVevents) {
- const exceptionEvent = new ICAL.Event(exceptionVevent, { exceptions: [] });
- if (exceptionEvent.uid !== event.uid) continue;
-
+ for (const exceptionVevent of exceptionVeventsByUid.get(event.uid) ?? []) {
event.relateException(exceptionVevent);
}