Refresh Fabric KPIs live while an LLDP collect job is running.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-04 21:56:01 +08:00
parent 2cbdc896f6
commit ba038a3af6
2 changed files with 16 additions and 1 deletions

View file

@ -111,6 +111,12 @@ def _run_discover_job(job_id: str, body: FabricDiscoverRequest) -> None:
job.edges_updated = updated
job.updated_at = _utcnow()
db.commit()
# Keep Fabric KPI cache roughly in sync during long runs (dashboard polls job).
if int(job.done or 0) % 50 == 0:
try:
refresh_fabric_stats(db)
except Exception: # noqa: BLE001
db.rollback()
# Absent on a successfully scanned endpoint → missing; purge after N cycles.
if scanned_ok: