"""Signal handlers for provisioning engine events."""

from __future__ import annotations

from simorgh.apps.events.bus import dispatch


def notify_fixture_executed(
    provider_name: str,
    items_created: int,
    items_updated: int,
    tenant_slug: str = "",
) -> None:
    dispatch(
        "fixture_executed",
        {
            "provider": provider_name,
            "items_created": items_created,
            "items_updated": items_updated,
            "tenant_slug": tenant_slug,
        },
        audit=False,
    )


def notify_seed_completed(
    fixture_names: list[str],
    total_created: int,
    tenant_slug: str = "",
) -> None:
    dispatch(
        "seed_completed",
        {
            "fixtures": fixture_names,
            "total_created": total_created,
            "tenant_slug": tenant_slug,
        },
        audit=False,
    )


def notify_snapshot_event(
    event_name: str,
    snapshot_name: str,
    file_path: str = "",
) -> None:
    dispatch(
        event_name,
        {
            "snapshot": snapshot_name,
            "file": file_path,
        },
        audit=False,
    )


def notify_benchmark_generated(
    spec_name: str,
    total_entities: int,
    duration_ms: int,
) -> None:
    dispatch(
        "benchmark_generated",
        {
            "spec": spec_name,
            "total_entities": total_entities,
            "duration_ms": duration_ms,
        },
        audit=False,
    )
