FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
25 lines
746 B
Python
25 lines
746 B
Python
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())
|