remove old incident, keep history only for 90d

pull/47/head
lyc8503 2024-06-30 21:54:57 +08:00
parent 6f7df0a37a
commit dcc2dbb278
2 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# 📈[UptimeFlare](https://github.com/lyc8503/UptimeFlare)
# [UptimeFlare](https://github.com/lyc8503/UptimeFlare)
A more advanced, serverless, and free uptime monitoring & status page solution, powered by Cloudflare Workers, complete with a user-friendly interface.
@ -44,4 +44,4 @@ Please refer to [Wiki](https://github.com/lyc8503/UptimeFlare/wiki)
- [ ] SSL certificate checks
- [ ] Self-host Dockerfile
- [ ] Incident timeline
- [ ] Remove old incidents
- [x] Remove old incidents

View File

@ -283,7 +283,27 @@ export default {
latencyLists.all.shift()
}
state.latency[monitor.id] = latencyLists
// TODO: discard old incidents
// discard old incidents
let incidentList = state.incident[monitor.id]
while (incidentList.length > 0 && incidentList[0].end && incidentList[0].end < currentTimeSecond - 90 * 24 * 60 * 60) {
incidentList.shift()
}
if (incidentList.length == 0 || (
incidentList[0].start[0] > currentTimeSecond - 90 * 24 * 60 * 60 &&
incidentList[0].error[0] != 'dummy'
)) {
// put the dummy incident back
incidentList.unshift(
{
start: [currentTimeSecond - 90 * 24 * 60 * 60],
end: currentTimeSecond - 90 * 24 * 60 * 60,
error: ['dummy'],
}
)
}
state.incident[monitor.id] = incidentList
statusChanged ||= monitorStatusChanged
}