remove old incident, keep history only for 90d
parent
6f7df0a37a
commit
dcc2dbb278
|
|
@ -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.
|
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
|
- [ ] SSL certificate checks
|
||||||
- [ ] Self-host Dockerfile
|
- [ ] Self-host Dockerfile
|
||||||
- [ ] Incident timeline
|
- [ ] Incident timeline
|
||||||
- [ ] Remove old incidents
|
- [x] Remove old incidents
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,27 @@ export default {
|
||||||
latencyLists.all.shift()
|
latencyLists.all.shift()
|
||||||
}
|
}
|
||||||
state.latency[monitor.id] = latencyLists
|
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
|
statusChanged ||= monitorStatusChanged
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue