Skip to content

Commit

Permalink
fix: fixed case where heartbeat with similar timestamp could shorten …
Browse files Browse the repository at this point in the history
…previous event
  • Loading branch information
ErikBjare committed Jun 30, 2020
1 parent 296647e commit 0444be3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aw_transform/heartbeats.py
Expand Up @@ -39,7 +39,8 @@ def heartbeat_merge(last_event: Event, heartbeat: Event, pulsetime: float) -> Op
if last_event.duration < timedelta(0):
logger.warning("Merging heartbeats would result in a negative duration, refusing to merge.")
else:
last_event.duration = new_duration
# Taking the max of durations ensures heartbeats that end before the last event don't shorten it
last_event.duration = max((last_event.duration, new_duration))
return last_event

return None

0 comments on commit 0444be3

Please sign in to comment.