️ 流量记录清理

This commit is contained in:
naiba
2021-07-15 00:07:02 +08:00
parent 63bb1570d2
commit 321ccce931
3 changed files with 7 additions and 3 deletions

View File

@@ -120,7 +120,11 @@ func cleanMonitorHistory() {
for id, couldRemove := range specialServerKeep {
dao.DB.Unscoped().Delete(&model.Transfer{}, "id = ? AND created_at < ?", id, couldRemove)
}
dao.DB.Unscoped().Delete(&model.Transfer{}, "id NOT IN (?) AND created_at < ?", specialServerIDs, allServerKeep)
if allServerKeep.IsZero() {
dao.DB.Unscoped().Delete(&model.Transfer{}, "id NOT IN (?)", specialServerIDs)
} else {
dao.DB.Unscoped().Delete(&model.Transfer{}, "id NOT IN (?) AND created_at < ?", specialServerIDs, allServerKeep)
}
}
func loadServers() {