mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 18:24:03 +00:00
Fix #922
This commit is contained in:
parent
76611ecaca
commit
dcc91d6c72
2 changed files with 16 additions and 8 deletions
|
@ -296,6 +296,9 @@ class Monitor extends BeanModel {
|
||||||
debug("heartbeatCount" + heartbeatCount + " " + time);
|
debug("heartbeatCount" + heartbeatCount + " " + time);
|
||||||
|
|
||||||
if (heartbeatCount <= 0) {
|
if (heartbeatCount <= 0) {
|
||||||
|
// Fix #922, since previous heartbeat could be inserted by api, it should get from database
|
||||||
|
previousBeat = await Monitor.getPreviousHeartbeat(this.id);
|
||||||
|
|
||||||
throw new Error("No heartbeat in the time window");
|
throw new Error("No heartbeat in the time window");
|
||||||
} else {
|
} else {
|
||||||
// No need to insert successful heartbeat for push type, so end here
|
// No need to insert successful heartbeat for push type, so end here
|
||||||
|
@ -751,6 +754,15 @@ class Monitor extends BeanModel {
|
||||||
debug("No notification, no need to send cert notification");
|
debug("No notification, no need to send cert notification");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getPreviousHeartbeat(monitorID) {
|
||||||
|
return await R.getRow(`
|
||||||
|
SELECT status, time FROM heartbeat
|
||||||
|
WHERE id = (select MAX(id) from heartbeat where monitor_id = ?)
|
||||||
|
`, [
|
||||||
|
monitorID
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Monitor;
|
module.exports = Monitor;
|
||||||
|
|
|
@ -31,12 +31,7 @@ router.get("/api/push/:pushToken", async (request, response) => {
|
||||||
throw new Error("Monitor not found or not active.");
|
throw new Error("Monitor not found or not active.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousHeartbeat = await R.getRow(`
|
const previousHeartbeat = await Monitor.getPreviousHeartbeat(monitor.id);
|
||||||
SELECT status, time FROM heartbeat
|
|
||||||
WHERE id = (select MAX(id) from heartbeat where monitor_id = ?)
|
|
||||||
`, [
|
|
||||||
monitor.id
|
|
||||||
]);
|
|
||||||
|
|
||||||
let status = UP;
|
let status = UP;
|
||||||
if (monitor.isUpsideDown()) {
|
if (monitor.isUpsideDown()) {
|
||||||
|
@ -158,7 +153,8 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request,
|
||||||
ON monitor_tag.tag_id = tag.id
|
ON monitor_tag.tag_id = tag.id
|
||||||
WHERE monitor_tag.monitor_id = ?`, [monitor.id]
|
WHERE monitor_tag.monitor_id = ?`, [monitor.id]
|
||||||
);
|
);
|
||||||
return {...monitor, tags: tags}
|
return { ...monitor,
|
||||||
|
tags: tags };
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue