added db
This commit is contained in:
@@ -8,12 +8,13 @@ import time
|
||||
|
||||
import uvicorn
|
||||
|
||||
from admin.models import get_active_flow_config, init_db, insert_run
|
||||
from db import flow_config_repo, init_db
|
||||
from db.repositories.runs import runs_repo
|
||||
from config import config
|
||||
|
||||
|
||||
def _load_active_flow() -> dict[str, object]:
|
||||
cfg = asyncio.run(get_active_flow_config())
|
||||
cfg = asyncio.run(flow_config_repo.get_active())
|
||||
if cfg is None:
|
||||
print("[WARN] No active flow config — running without dynamic flow steps.", file=sys.stderr)
|
||||
return cfg or {}
|
||||
@@ -30,7 +31,7 @@ def _record(
|
||||
|
||||
total_ms = int((time.monotonic() - t0) * 1000)
|
||||
if exc is not None:
|
||||
asyncio.run(insert_run(scenario, identifier, False, str(exc), [], total_ms))
|
||||
asyncio.run(runs_repo.insert(scenario, identifier, False, str(exc), [], total_ms))
|
||||
print(f"[FAIL] {identifier}: {exc}", file=sys.stderr)
|
||||
return
|
||||
|
||||
@@ -39,13 +40,13 @@ def _record(
|
||||
{"name": s.name, "success": s.success, "error": s.error, "duration_ms": s.duration_ms}
|
||||
for s in flow_result.steps
|
||||
]
|
||||
asyncio.run(insert_run(
|
||||
asyncio.run(runs_repo.insert(
|
||||
scenario, identifier, flow_result.success,
|
||||
flow_result.failure_reason, steps_data, total_ms,
|
||||
))
|
||||
status = "OK" if flow_result.success else f"FAIL ({flow_result.failure_reason})"
|
||||
else:
|
||||
asyncio.run(insert_run(scenario, identifier, True, None, [], total_ms))
|
||||
asyncio.run(runs_repo.insert(scenario, identifier, True, None, [], total_ms))
|
||||
status = "OK (no flow config)"
|
||||
|
||||
print(f"[{status}] {identifier} — {total_ms} ms")
|
||||
|
||||
Reference in New Issue
Block a user