You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
# backend/app/connectors/calendar/__init__.py — 캘린더 읽기 커넥터 + phase-13 sync 프레임워크
|
|
# 읽기 경로는 CalEvent/Meeting 테이블을 직접 읽는다(Google sync 가 적재한 실데이터).
|
|
# (sync 커넥터는 같은 패키지의 real_google.py/ics_import.py)
|
|
from typing import Optional
|
|
|
|
from sqlmodel import Session, select
|
|
|
|
from ...models import CalEvent, Meeting
|
|
from ..base import CalendarConnector
|
|
|
|
|
|
class CalendarReadConnector(CalendarConnector):
|
|
"""캘린더 페이지 읽기 경로. CalEvent/Meeting 테이블을 그대로 읽는다.
|
|
실제 일정 유입은 Google Calendar sync(real_google.py)가 같은 테이블에 적재한다(메일과 동일)."""
|
|
|
|
def list_events(self, s: Session, day: Optional[int] = None) -> list[dict]:
|
|
q = select(CalEvent)
|
|
if day is not None:
|
|
q = q.where(CalEvent.day == day)
|
|
rows = s.exec(q.order_by(CalEvent.day, CalEvent.start)).all()
|
|
return [r.model_dump() for r in rows]
|
|
|
|
def get_meeting(self, s: Session, meeting_id: str) -> Optional[dict]:
|
|
m = s.get(Meeting, meeting_id)
|
|
return m.model_dump() if m else None
|
|
|
|
def write_event(self, s: Session, payload: dict) -> dict:
|
|
ev = CalEvent(**payload)
|
|
s.add(ev)
|
|
s.commit()
|
|
return ev.model_dump()
|
|
|
|
|
|
def get_calendar_connector() -> CalendarReadConnector:
|
|
return CalendarReadConnector()
|