Align: do not append points with the same timestamp

This commit is contained in:
Alexander Zobnin
2021-09-23 15:59:23 +03:00
parent 59ce70df4b
commit 750292296c

View File

@@ -40,7 +40,12 @@ func (ts TimeSeries) Align(interval time.Duration) TimeSeries {
}
}
alignedTs = append(alignedTs, TimePoint{Time: pointFrameTs, Value: point.Value})
if len(alignedTs) > 0 && alignedTs[len(alignedTs)-1].Time == pointFrameTs {
// Do not append points with the same timestamp
alignedTs[len(alignedTs)-1] = TimePoint{Time: pointFrameTs, Value: point.Value}
} else {
alignedTs = append(alignedTs, TimePoint{Time: pointFrameTs, Value: point.Value})
}
frameTs = frameTs.Add(interval)
}