from typing import Optional, Sequence from sqlalchemy import select, desc from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import joinedload from app.domain.models import Appointment class AppointmentsRepository: def __init__(self, db: AsyncSession): self.db = db async def get_all(self) -> Sequence[Appointment]: stmt = ( select(Appointment) .options(joinedload(Appointment.type)) .options(joinedload(Appointment.patient)) .order_by(desc(Appointment.)) ) result = await self.db.execute(stmt) return result.scalars().all() async def get_by_doctor_id(self, doctor_id: int): stmt = ( select(Appointment) .options(joinedload(Appointment.type)) .options(joinedload(Appointment.patient)) .filter() )