"""Plnění audit_interval pro dokončené 15min sloty (volá ems.fn_fill_audit_interval)."""

from __future__ import annotations

import logging

logger = logging.getLogger(__name__)


async def fill_audit_for_completed_intervals(site_id: int, db) -> None:
    """
    Naplní audit_interval pro dokončené 15min sloty přes ems.fn_fill_audit_for_site_window.
    """
    n = await db.fetchval(
        "select ems.fn_fill_audit_for_site_window($1::int, 6)",
        site_id,
    )
    if n:
        logger.info("[site=%s] Filled %s missing audit intervals", site_id, int(n))
