@@ -154,9 +154,9 @@ func (v *apiV1) monitorHistoriesById(c *gin.Context) {
154154 if singleton .Conf .DatabaseType == "badger" {
155155 // BadgerDB 模式下使用 MonitorAPI,只查询最近7天的ICMP/TCP监控数据
156156 if singleton .MonitorAPI != nil {
157- // 恢复原始查询逻辑:查询所有监控历史记录
157+ // 查询最近7天的监控历史记录
158158 endTime := time .Now ()
159- startTime := endTime .AddDate (0 , 0 , - 7 ) // 恢复原始的7天数据
159+ startTime := endTime .AddDate (0 , 0 , - 7 ) // 显示7天数据
160160
161161 if db .DB != nil {
162162 // 恢复原始的查询方法
@@ -177,20 +177,14 @@ func (v *apiV1) monitorHistoriesById(c *gin.Context) {
177177 }
178178 }
179179
180- // 恢复原始的记录过滤
180+ // 修复:正确的记录过滤,不限制总数,应该返回所有匹配的记录
181181 var networkHistories []* model.MonitorHistory
182- count := 0
183- maxRecords := 1000 // 恢复原始的记录数限制
184182
185183 for _ , history := range allHistories {
186- if count >= maxRecords {
187- break
188- }
189184 if history != nil && history .ServerID == server .ID {
190185 if monitorType , exists := monitorTypeMap [history .MonitorID ]; exists &&
191186 (monitorType == model .TaskTypeICMPPing || monitorType == model .TaskTypeTCPPing ) {
192187 networkHistories = append (networkHistories , history )
193- count ++
194188 }
195189 }
196190 }
@@ -208,8 +202,8 @@ func (v *apiV1) monitorHistoriesById(c *gin.Context) {
208202 if singleton .DB != nil {
209203 var networkHistories []* model.MonitorHistory
210204
211- // 恢复原始的30天数据查询
212- startTime := time .Now ().AddDate (0 , 0 , - 30 )
205+ // 查询最近7天的数据
206+ startTime := time .Now ().AddDate (0 , 0 , - 7 )
213207
214208 err := singleton .DB .Where ("server_id = ? AND created_at > ? AND monitor_id IN (SELECT id FROM monitors WHERE type IN (?, ?))" ,
215209 server .ID , startTime , model .TaskTypeICMPPing , model .TaskTypeTCPPing ).
0 commit comments