48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Backwards-compatibility shim — delegates to db.repositories."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from db.connection import DB_PATH as DB_PATH, init_db as init_db
|
|
from db.repositories import flow_config_repo as flow_config_repo, runs_repo
|
|
|
|
FlowConfigRow = dict[str, Any]
|
|
|
|
|
|
# ── runs ─────────────────────────────────────────────────────────────────────
|
|
|
|
async def insert_run(
|
|
scenario: str,
|
|
identifier: str,
|
|
success: bool,
|
|
failure_reason: str | None,
|
|
steps: list[dict[str, Any]],
|
|
total_ms: int,
|
|
) -> int:
|
|
return await runs_repo.insert(scenario, identifier, success, failure_reason, steps, total_ms)
|
|
|
|
|
|
async def get_stats() -> dict[str, Any]:
|
|
return await runs_repo.stats()
|
|
|
|
|
|
# ── flow_configs ──────────────────────────────────────────────────────────────
|
|
|
|
async def list_flow_configs() -> list[FlowConfigRow]:
|
|
return await flow_config_repo.list()
|
|
|
|
|
|
async def get_flow_config(cfg_id: int) -> FlowConfigRow | None:
|
|
return await flow_config_repo.get(cfg_id)
|
|
|
|
|
|
async def upsert_flow_config(data: dict[str, Any], cfg_id: int | None = None) -> int:
|
|
if cfg_id is None:
|
|
return await flow_config_repo.create(data)
|
|
await flow_config_repo.update(cfg_id, data)
|
|
return cfg_id
|
|
|
|
|
|
async def delete_flow_config(cfg_id: int) -> None:
|
|
await flow_config_repo.delete(cfg_id)
|