from typing import Optional, Sequence

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

from app.domain.models import AppointmentType


class AppointmentTypesRepository:
    def __init__(self, db: AsyncSession):
        self.db = db

    async def get_all(self) -> Sequence[AppointmentType]:
        stmt = select(AppointmentType)
        result = await self.db.execute(stmt)
        return result.scalars().all()

    async def get_by_id(self, appointment_type_id: int) -> Optional[AppointmentType]:
        stmt = select(AppointmentType).filter_by(id=appointment_type_id)
        result = await self.db.execute(stmt)
        return result.scalars().first()
