Commit 841fb74b by utkarshcmu

Reversed loop for last function

parent 74632b5e
...@@ -63,10 +63,12 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float { ...@@ -63,10 +63,12 @@ func (s *SimpleReducer) Reduce(series *tsdb.TimeSeries) null.Float {
value = float64(len(series.Points)) value = float64(len(series.Points))
allNull = false allNull = false
case "last": case "last":
for _, point := range series.Points { points := series.Points
if point[0].Valid { for i := len(points) - 1; i >= 0; i-- {
value = point[0].Float64 if points[i][0].Valid {
value = points[i][0].Float64
allNull = false allNull = false
break
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment