Remove 90-day history (not used) to avoid CPU limit exceed on free tier

pull/97/head
lyc8503 2025-03-24 20:55:49 +08:00 committed by GitHub
parent a0eabeec45
commit e448e95909
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 7 deletions

View File

@ -262,8 +262,8 @@ export default {
// append to latency data
let latencyLists = state.latency[monitor.id] || {
recent: [],
all: [],
}
latencyLists.all = []
const record = {
loc: checkLocation,
@ -271,17 +271,11 @@ export default {
time: currentTimeSecond,
}
latencyLists.recent.push(record)
if (latencyLists.all.length === 0 || currentTimeSecond - latencyLists.all.slice(-1)[0].time > 60 * 60) {
latencyLists.all.push(record)
}
// discard old data
while (latencyLists.recent[0]?.time < currentTimeSecond - 12 * 60 * 60) {
latencyLists.recent.shift()
}
while (latencyLists.all[0]?.time < currentTimeSecond - 90 * 24 * 60 * 60) {
latencyLists.all.shift()
}
state.latency[monitor.id] = latencyLists
// discard old incidents