mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-14 19:02:22 +02:00
Squash Odysseus development history
This commit is contained in:
@@ -69,11 +69,17 @@ def _parse_dt(s: str) -> datetime:
|
||||
return datetime.fromisoformat(s.replace("Z", "+00:00"))
|
||||
|
||||
|
||||
def _calendar_name(ev: "CalendarEvent") -> str:
|
||||
cal = getattr(ev, "calendar", None)
|
||||
name = getattr(cal, "name", "") if cal else ""
|
||||
return name if isinstance(name, str) else ""
|
||||
|
||||
|
||||
def _serialize_event(ev: "CalendarEvent") -> dict:
|
||||
return {
|
||||
"uid": ev.uid,
|
||||
"calendar_id": ev.calendar_id,
|
||||
"calendar_name": ev.calendar.name if ev.calendar else "",
|
||||
"calendar_name": _calendar_name(ev),
|
||||
"summary": ev.summary,
|
||||
"description": ev.description or "",
|
||||
"location": ev.location or "",
|
||||
@@ -97,9 +103,13 @@ def cmd_list(args) -> None:
|
||||
end = _parse_dt(args.end) if args.end else (start + timedelta(days=30))
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# Overlap semantics, matching the web route (routes/calendar_routes.py)
|
||||
# and the recurring-expansion contract: an event is in the window when
|
||||
# it starts before the window end AND ends after the window start. This
|
||||
# includes multi-day / in-progress events that began before `start`.
|
||||
q = db.query(CalendarEvent).filter(
|
||||
CalendarEvent.dtstart >= start,
|
||||
CalendarEvent.dtstart < end,
|
||||
CalendarEvent.dtend > start,
|
||||
)
|
||||
if args.calendar:
|
||||
cal = db.query(CalendarCal).filter(CalendarCal.name == args.calendar).first()
|
||||
|
||||
Reference in New Issue
Block a user