from __future__ import annotations import uuid from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession from app.models.notification_delivery import NotificationDelivery class NotificationDeliveryRepository: def __init__(self, db: AsyncSession) -> None: self.db = db async def create(self, delivery: NotificationDelivery) -> NotificationDelivery: self.db.add(delivery) await self.db.flush() return delivery async def list_for_alert(self, alert_id: uuid.UUID) -> list[NotificationDelivery]: result = await self.db.execute( select(NotificationDelivery).where(NotificationDelivery.alert_id == alert_id) ) return list(result.scalars().all())