mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 12:56:02 +08:00
fix: metrics order by avg (#5029)
This commit is contained in:
parent
9ff0e34038
commit
cf64da2631
@ -40,7 +40,7 @@ func applyMetricLimit(results []*v3.Result, queryRangeParams *v3.QueryRangeParam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ithSum, jthSum, ithCount, jthCount := 0.0, 0.0, 1.0, 1.0
|
ithSum, jthSum, ithCount, jthCount := 0.0, 0.0, 0.0, 0.0
|
||||||
for _, point := range result.Series[i].Points {
|
for _, point := range result.Series[i].Points {
|
||||||
if math.IsNaN(point.Value) || math.IsInf(point.Value, 0) {
|
if math.IsNaN(point.Value) || math.IsInf(point.Value, 0) {
|
||||||
continue
|
continue
|
||||||
@ -57,6 +57,10 @@ func applyMetricLimit(results []*v3.Result, queryRangeParams *v3.QueryRangeParam
|
|||||||
jthCount++
|
jthCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// avoid division by zero
|
||||||
|
ithCount = math.Max(ithCount, 1)
|
||||||
|
jthCount = math.Max(jthCount, 1)
|
||||||
|
|
||||||
if orderBy.Order == "asc" {
|
if orderBy.Order == "asc" {
|
||||||
return ithSum/ithCount < jthSum/jthCount
|
return ithSum/ithCount < jthSum/jthCount
|
||||||
} else if orderBy.Order == "desc" {
|
} else if orderBy.Order == "desc" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user