feat: implement collection runs tracking and error acknowledgment features
This commit is contained in:
1 parent
c39364eda4
commit
34903492f6
14 files changed
+484
-21
No files matched your search
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_DB_PATH = "cost_dashboard.db"
|
||||
@@ -134,6 +135,30 @@ def set_resource_collection_status(
|
||||
conn.commit()
|
||||
|
||||
|
||||
def start_collection_run(conn: sqlite3.Connection, run_type: str) -> int:
|
||||
"""Enregistre le début d'une exécution de collecte (page "Collecte" du
|
||||
dashboard). `run_type` : 'daily' (collect.py) ou 'backfill'
|
||||
(backfill_historical.py)."""
|
||||
cur = conn.execute(
|
||||
"INSERT INTO collection_runs (run_type, started_at) VALUES (?, ?)",
|
||||
(run_type, datetime.now(timezone.utc).isoformat()),
|
||||
)
|
||||
conn.commit()
|
||||
return cur.lastrowid
|
||||
|
||||
|
||||
def finish_collection_run(conn: sqlite3.Connection, run_id: int, tenants_ok: int, tenants_error: int) -> None:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE collection_runs
|
||||
SET finished_at = ?, tenants_ok = ?, tenants_error = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(datetime.now(timezone.utc).isoformat(), tenants_ok, tenants_error, run_id),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def upsert_resource_costs(
|
||||
conn: sqlite3.Connection,
|
||||
provider: str,
|
||||
|
||||
Reference in new issue
Block a user