cestina, UI, UX
This commit is contained in:
@@ -172,6 +172,32 @@ def get_operations_snapshot():
|
||||
online_all = con.execute("SELECT last_seen_at FROM workers").fetchall()
|
||||
workers_online = sum(1 for worker in online_all if is_worker_online(worker["last_seen_at"]))
|
||||
|
||||
app_columns = _table_columns(con, "apps")
|
||||
if "enabled" in app_columns:
|
||||
active_applications = con.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM apps
|
||||
WHERE enabled = 1
|
||||
OR LOWER(CAST(enabled AS TEXT)) IN ('1', 'true', 'yes', 'enabled')
|
||||
"""
|
||||
).fetchone()["count"]
|
||||
else:
|
||||
active_applications = con.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM apps
|
||||
WHERE LOWER(COALESCE(status, '')) NOT IN ('disabled', 'deleted', 'archived')
|
||||
"""
|
||||
).fetchone()["count"]
|
||||
problematic_applications = con.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM apps
|
||||
WHERE LOWER(COALESCE(status, '')) IN ('failed', 'error', 'disabled', 'deleted', 'archived')
|
||||
"""
|
||||
).fetchone()["count"]
|
||||
|
||||
jobs_summary = con.execute(
|
||||
"""
|
||||
SELECT
|
||||
@@ -190,6 +216,15 @@ def get_operations_snapshot():
|
||||
LIMIT 20
|
||||
"""
|
||||
).fetchall()
|
||||
recent_failed_jobs = con.execute(
|
||||
"""
|
||||
SELECT id, type, target_type, target_id, status, source, created_at, started_at, finished_at
|
||||
FROM jobs
|
||||
WHERE status = 'failed'
|
||||
ORDER BY id DESC
|
||||
LIMIT 10
|
||||
"""
|
||||
).fetchall()
|
||||
|
||||
deployments_summary = con.execute(
|
||||
f"""
|
||||
@@ -201,6 +236,24 @@ def get_operations_snapshot():
|
||||
""",
|
||||
(*DEPLOYMENT_RUNNING_STATUSES, *DEPLOYMENT_FAILED_STATUSES, *DEPLOYMENT_SUCCESS_STATUSES),
|
||||
).fetchone()
|
||||
deployment_columns = _table_columns(con, "deployments")
|
||||
deployments_today = 0
|
||||
if "created_at" in deployment_columns:
|
||||
deployments_today = con.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM deployments
|
||||
WHERE date(created_at) = date('now')
|
||||
"""
|
||||
).fetchone()["count"]
|
||||
elif "started_at" in deployment_columns:
|
||||
deployments_today = con.execute(
|
||||
"""
|
||||
SELECT COUNT(*) AS count
|
||||
FROM deployments
|
||||
WHERE date(started_at) = date('now')
|
||||
"""
|
||||
).fetchone()["count"]
|
||||
recent_deployments = con.execute(
|
||||
"""
|
||||
SELECT id, app_id, kind, status, started_at, finished_at, trigger_source
|
||||
@@ -217,6 +270,16 @@ def get_operations_snapshot():
|
||||
LIMIT 20
|
||||
"""
|
||||
).fetchall()
|
||||
recent_failed_deployments = con.execute(
|
||||
f"""
|
||||
SELECT id, app_id, kind, status, started_at, finished_at, trigger_source
|
||||
FROM deployments
|
||||
WHERE LOWER(COALESCE(status, '')) IN ({','.join('?' for _ in DEPLOYMENT_FAILED_STATUSES)})
|
||||
ORDER BY id DESC
|
||||
LIMIT 10
|
||||
""",
|
||||
DEPLOYMENT_FAILED_STATUSES,
|
||||
).fetchall()
|
||||
|
||||
con.close()
|
||||
return {
|
||||
@@ -227,6 +290,11 @@ def get_operations_snapshot():
|
||||
"failed_24h": jobs_summary["failed_24h"] or 0,
|
||||
"success_24h": jobs_summary["success_24h"] or 0,
|
||||
"recent": [dict(row) for row in recent_jobs],
|
||||
"recent_failed": [dict(row) for row in recent_failed_jobs],
|
||||
},
|
||||
"apps": {
|
||||
"active": active_applications,
|
||||
"problematic": problematic_applications,
|
||||
},
|
||||
"workers": {
|
||||
"online": workers_online,
|
||||
@@ -237,7 +305,9 @@ def get_operations_snapshot():
|
||||
"running": deployments_summary["running"] or 0,
|
||||
"failed_24h": deployments_summary["failed_24h"] or 0,
|
||||
"success_24h": deployments_summary["success_24h"] or 0,
|
||||
"today": deployments_today,
|
||||
"recent": [dict(row) for row in recent_deployments],
|
||||
"recent_failed": [dict(row) for row in recent_failed_deployments],
|
||||
},
|
||||
"audit": {
|
||||
"recent": [dict(row) for row in recent_audit],
|
||||
|
||||
Reference in New Issue
Block a user