Skip to content

Commit

Permalink
Align: do not append points with the same timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Sep 23, 2021
1 parent 59ce70d commit 7502922
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/timeseries/align.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 7502922

Please sign in to comment.