from sqlalchemy.ext.asyncio import AsyncSession from app.notifications.models import NotificationLog async def create_notification_log(db: AsyncSession, *, user_id: int, event_type: str, payload: str) -> None: db.add(NotificationLog(user_id=user_id, event_type=event_type, payload=payload)) async def list_user_notifications(db: AsyncSession, *, user_id: int, limit: int = 50) -> list[NotificationLog]: from sqlalchemy import select result = await db.execute( select(NotificationLog) .where(NotificationLog.user_id == user_id) .order_by(NotificationLog.id.desc()) .limit(limit) ) return list(result.scalars().all())