fix(health): 修复工作台统计 SQL 表名 — alerts/follow_up_task
- alert → alerts(实际表名复数) - follow_up_plan → follow_up_task(表不存在,改用 pending 状态的随访任务)
This commit is contained in:
@@ -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()],
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user