diff --git a/backend/open_webui/models/calendar.py b/backend/open_webui/models/calendar.py index 48b28d8e9a..75ccfcab1c 100644 --- a/backend/open_webui/models/calendar.py +++ b/backend/open_webui/models/calendar.py @@ -696,6 +696,7 @@ class CalendarEventTable: self, now_ns: int, default_lookahead_ns: int, + grace_ns: int = 0, db: Optional[AsyncSession] = None, ) -> list[tuple[CalendarEventModel, Optional[str]]]: """Events starting between now and now + lookahead, for alert processing. @@ -716,7 +717,7 @@ class CalendarEventTable: .outerjoin(UserRow, UserRow.id == CalendarEvent.user_id) .filter( CalendarEvent.is_cancelled == False, - CalendarEvent.start_at >= now_ns, + CalendarEvent.start_at >= now_ns - grace_ns, CalendarEvent.start_at <= upper, ) ) diff --git a/backend/open_webui/utils/automations.py b/backend/open_webui/utils/automations.py index 05955d54d9..bb72a999b5 100644 --- a/backend/open_webui/utils/automations.py +++ b/backend/open_webui/utils/automations.py @@ -501,9 +501,10 @@ async def _check_calendar_alerts(app) -> None: now_ns = int(time.time_ns()) default_lookahead_ns = CALENDAR_ALERT_LOOKAHEAD_MINUTES * 60 * 1_000_000_000 + grace_ns = SCHEDULER_POLL_INTERVAL * 1_000_000_000 async with get_async_db() as db: - upcoming = await CalendarEvents.get_upcoming_events(now_ns, default_lookahead_ns, db=db) + upcoming = await CalendarEvents.get_upcoming_events(now_ns, default_lookahead_ns,grace_ns=grace_ns, db=db) if not upcoming: return