krz/hutch-notify

Notification server for Hutch.

clone: git clone https://gitbay.org/krz/hutch-notify.git

main: app/poller.py · raw

 1from sqlalchemy import select
 2from sqlalchemy.ext.asyncio import AsyncSession
 3from app.models import Subscription, Event, Delivery, Device
 4
 5
 6async def poll_builds_once(db: AsyncSession) -> None:
 7    # Placeholder.
 8    # Replace with sr.ht fetch logic.
 9    # Strategy:
10    # 1. query distinct build subscriptions
11    # 2. fetch latest builds per source_id
12    # 3. create Event rows for unseen terminal states
13    # 4. create Delivery rows for enabled devices subscribed to matching event_type
14    subscribed = await db.execute(
15        select(Subscription).where(Subscription.source_type == "build", Subscription.is_enabled.is_(True))
16    )
17    subscriptions = subscribed.scalars().all()
18
19    # no-op until sr.ht integration is wired
20    _ = subscriptions