Prechádzať zdrojové kódy

优化接口列表无数据时返回不正常问题

路佳明 2 týždňov pred
rodič
commit
f36ea64010
1 zmenil súbory, kde vykonal 12 pridanie a 0 odobranie
  1. 12 0
      app/observe/service/urlmapping.go

+ 12 - 0
app/observe/service/urlmapping.go

@@ -1292,6 +1292,18 @@ func (s *UrlMapping) subStatsFromClickhouse(wg *sync.WaitGroup, req *dto.UrlMapp
 	if item.Total > 0 {
 		item.ErrorRate = float64(row.ErrorNum) / float64(row.Total)
 	}
+	if math.IsNaN(row.AvgDuration) || math.IsInf(row.AvgDuration, 0) {
+		row.AvgDuration = 0
+	}
+	if math.IsNaN(row.P50Duration) || math.IsInf(row.P50Duration, 0) {
+		row.P50Duration = 0
+	}
+	if math.IsNaN(row.P90Duration) || math.IsInf(row.P90Duration, 0) {
+		row.P90Duration = 0
+	}
+	if math.IsNaN(row.P99Duration) || math.IsInf(row.P99Duration, 0) {
+		row.P99Duration = 0
+	}
 	item.ErrorNum = row.ErrorNum
 	item.DurationMax = row.MaxDuration
 	item.DurationAvg = row.AvgDuration