Skip to content

Commit 0444be3

Browse files
committed
fix: fixed case where heartbeat with similar timestamp could shorten previous event
1 parent 296647e commit 0444be3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aw_transform/heartbeats.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def heartbeat_merge(last_event: Event, heartbeat: Event, pulsetime: float) -> Op
3939
if last_event.duration < timedelta(0):
4040
logger.warning("Merging heartbeats would result in a negative duration, refusing to merge.")
4141
else:
42-
last_event.duration = new_duration
42+
# Taking the max of durations ensures heartbeats that end before the last event don't shorten it
43+
last_event.duration = max((last_event.duration, new_duration))
4344
return last_event
4445

4546
return None

0 commit comments

Comments
 (0)