mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 05:30:05 +00:00
🗑 优化无效数据清理
This commit is contained in:
@@ -93,7 +93,10 @@ func recordTransferHourlyUsage() {
|
||||
}
|
||||
|
||||
func cleanMonitorHistory() {
|
||||
dao.DB.Unscoped().Delete(&model.MonitorHistory{}, "created_at < ?", time.Now().AddDate(0, 0, -30))
|
||||
// 清理无效数据
|
||||
dao.DB.Unscoped().Delete(&model.MonitorHistory{}, "created_at < ? OR monitor_id NOT IN (SELECT `id` FROM monitors)", time.Now().AddDate(0, 0, -30))
|
||||
dao.DB.Unscoped().Delete(&model.Transfer{}, "server_id NOT IN (SELECT `id` FROM servers)")
|
||||
// 计算可清理流量记录的时长
|
||||
var allServerKeep time.Time
|
||||
specialServerKeep := make(map[uint64]time.Time)
|
||||
var specialServerIDs []uint64
|
||||
|
||||
Reference in New Issue
Block a user