From 8a550a5523ceb33edd02441a1585519d3b0d763b Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Fri, 29 Nov 2024 23:17:59 +0100 Subject: [PATCH] fix SummarizeValues to return last non-NaN value --- expr/consolidations/consolidations.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/expr/consolidations/consolidations.go b/expr/consolidations/consolidations.go index 4ae01b726..908e3afb9 100644 --- a/expr/consolidations/consolidations.go +++ b/expr/consolidations/consolidations.go @@ -188,7 +188,13 @@ func SummarizeValues(f string, values []float64, XFilesFactor float32) float64 { } } case "last", "current": - rv = values[len(values)-1] + rv = math.NaN() + for i := len(values) - 1; i >= 0; i-- { + if !math.IsNaN(values[i]) { + rv = values[i] + break + } + } total = notNans(values) case "range", "rangeOf": vMax := math.Inf(-1)