fix: update monitor sql

This commit is contained in:
zaunist committed 2025-04-29 00:49:04 +08:00
1 parent ca4ddeac65
commit e0473bffdb
1 file changed
+6 -1
+6 -1
View File
@@ -200,7 +200,7 @@ export async function updateMonitorStatus(
response_time = ?,
uptime = (
SELECT ROUND((COUNT(CASE WHEN status = 'up' THEN 1 ELSE NULL END) * 100.0 / COUNT(*)), 2)
FROM monitor_status_history
FROM monitor_status_history_24h
WHERE monitor_id = ?
ORDER BY timestamp DESC
LIMIT 100
@@ -375,6 +375,11 @@ export async function deleteMonitor(db: Bindings["DB"], id: number) {
.bind(id)
.run();
await db
.prepare("DELETE FROM monitor_status_history_24h WHERE monitor_id = ?")
.bind(id)
.run();
// 执行删除监控
return await db.prepare("DELETE FROM monitors WHERE id = ?").bind(id).run();
}