diff --git a/api/ovdashboard_api/core/caldav.py b/api/ovdashboard_api/core/caldav.py index 8b62093..bd885b4 100644 --- a/api/ovdashboard_api/core/caldav.py +++ b/api/ovdashboard_api/core/caldav.py @@ -47,13 +47,13 @@ class CalDAV: _logger.debug("calendars") return [str(cal.name) for cal in cls.principal.calendars()] + @classmethod @AsyncTTL( time_to_live=SETTINGS.caldav.cache_ttl, maxsize=SETTINGS.caldav.cache_size, skip_args=1, ) @asyncify - @classmethod def get_calendar(cls, calendar_name: str) -> Calendar: """ Get a calendar by name using the CalDAV principal object. @@ -62,6 +62,12 @@ class CalDAV: return cls.principal.calendar(calendar_name) @classmethod + @AsyncTTL( + time_to_live=SETTINGS.caldav.cache_ttl, + maxsize=SETTINGS.caldav.cache_size, + skip_args=1, + ) + @asyncify def get_events(cls, calendar_name: str, cfg: Config) -> list[CalEvent]: """ Get a sorted list of events by CalDAV calendar name. diff --git a/api/ovdashboard_api/routers/v1/aggregate.py b/api/ovdashboard_api/routers/v1/aggregate.py index 1babc97..1238c7e 100644 --- a/api/ovdashboard_api/routers/v1/aggregate.py +++ b/api/ovdashboard_api/routers/v1/aggregate.py @@ -58,6 +58,6 @@ async def get_aggregate_calendar( for cal_prefix in cfg.calendar.aggregates[name]: cal_name = await LM_CALENDARS.getter.func(cal_prefix) - events.extend(CalDAV.get_events(cal_name, cfg)) + events.extend(await CalDAV.get_events(cal_name, cfg)) return sorted(events) diff --git a/api/ovdashboard_api/routers/v1/calendar.py b/api/ovdashboard_api/routers/v1/calendar.py index e5a34bd..aa6ec33 100644 --- a/api/ovdashboard_api/routers/v1/calendar.py +++ b/api/ovdashboard_api/routers/v1/calendar.py @@ -52,7 +52,7 @@ async def get_calendar( name: str = Depends(LM_CALENDARS.getter.func), cfg: Config = Depends(get_config), ) -> list[CalEvent]: - return CalDAV.get_events(name, cfg) + return await CalDAV.get_events(name, cfg) @router.get("/config")