mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: duration aggregation for heartbeats with identical timestamps (resolve #340)
This commit is contained in:
@ -80,8 +80,12 @@ func (srv *DurationService) Get(from, to time.Time, user *models.User, filters *
|
||||
|
||||
for _, list := range mapping {
|
||||
for _, d := range list {
|
||||
// will only happen if two heartbeats with different hashes (e.g. different project) have the same timestamp
|
||||
// that, in turn, will most likely only happen for mysql, where `time` column's precision was set to second for a while
|
||||
// assume that two non-identical heartbeats with identical time are sub-second apart from each other, so round up to expectancy value
|
||||
// also see https://github.com/muety/wakapi/issues/340
|
||||
if d.Duration == 0 {
|
||||
d.Duration = HeartbeatDiffThreshold
|
||||
d.Duration = 500 * time.Millisecond
|
||||
}
|
||||
durations = append(durations, d)
|
||||
}
|
||||
|
Reference in New Issue
Block a user