perf(calendar): pre-filter ICS text before parsing#4168
perf(calendar): pre-filter ICS text before parsing#4168KristjanESPERANTO wants to merge 1 commit into
Conversation
Drop simple one-off events outside the configured date window before passing the ICS text to node-ical. Recurring events and overrides are kept, because their actual instances need the normal expansion logic. The pre-filter is conservative: if an event cannot be classified cheaply, it stays in the feed and the parser handles it as before. This keeps the optimization local while reducing parser work for calendars with many old non-recurring events. Ref MagicMirrorOrg#4103
|
Just a thought: would a library like https://github.com/runely/ics-filter offload some complexity from this PR? |
|
@rejas that filters out ALL past events (we want SOME, sometimes)
|
|
i also replied in the issue, not in the PR. |
|
Thanks @rejas for the pointer to I'm setting this to draft for now and waiting for the author to respond. I'd rather improve an existing package than maintain our own implementation here :) |
We can pass |
This adds a pre-filter before parsing calendar ICS data. It drops simple one-off events that are clearly outside the configured date range, so
node-icalhas less work to do on large calendars.Recurring events, overrides,
RDATE, and unclear cases are kept and still handled by the normal parser logic.I’ve spent quite a bit of time tightening this up because calendar data can be tricky. The pre-filter is intentionally conservative: when it is not sure, it keeps the event and lets the existing parser handle it.
Why? Some calendars contain years of old non-recurring events. Parsing all of them is unnecessary when MagicMirror only needs the configured visible window.
Doubts: The whole thing is a bit complex, and I'm wondering whether it makes sense to merge it. There have been hardly any complaints, and sooner or later, we won't be supporting slow Raspberry Pis anymore anyway (see #3796). Is it worth increasing the complexity of our codebase?
Solves #4103.