fix(health): 修复工作台统计 SQL 表名 — alerts/follow_up_task
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- alert → alerts(实际表名复数)
- follow_up_plan → follow_up_task(表不存在,改用 pending 状态的随访任务)
This commit is contained in:
iven
2026-05-01 21:42:53 +08:00
parent 4aa014de0d
commit 963556c079

View File

@@ -490,7 +490,7 @@ pub async fn get_workbench_stats(
let urgent_alerts: i64 = FromQueryResult::find_by_statement(
Statement::from_sql_and_values(
DatabaseBackend::Postgres,
"SELECT COUNT(*) AS cnt FROM alert WHERE tenant_id = $1 AND severity = 'urgent' AND status = 'active' AND deleted_at IS NULL",
"SELECT COUNT(*) AS cnt FROM alerts WHERE tenant_id = $1 AND severity = 'urgent' AND status = 'active' AND deleted_at IS NULL",
[tenant_id.into()],
),
)
@@ -503,7 +503,7 @@ pub async fn get_workbench_stats(
let followup_due: i64 = FromQueryResult::find_by_statement(
Statement::from_sql_and_values(
DatabaseBackend::Postgres,
"SELECT COUNT(*) AS cnt FROM follow_up_plan WHERE tenant_id = $1 AND status = 'scheduled' AND next_date <= NOW() AND deleted_at IS NULL",
"SELECT COUNT(*) AS cnt FROM follow_up_task WHERE tenant_id = $1 AND status = 'pending' AND deleted_at IS NULL",
[tenant_id.into()],
),
)