diff --git a/personal_data/activity.py b/personal_data/activity.py index aed2a29..4f9033b 100644 --- a/personal_data/activity.py +++ b/personal_data/activity.py @@ -47,7 +47,7 @@ class RealizedActivitySample(ActivitySample): def heuristically_realize_samples( samples: list[ActivitySample], - default_estimated_duration: datetime.timedelta = DEFAULT_ESTIMATED_DURATION, + default_estimated_duration: datetime.timedelta | None = DEFAULT_ESTIMATED_DURATION, ) -> Iterator[RealizedActivitySample]: """Secret sauce. @@ -55,6 +55,9 @@ def heuristically_realize_samples( * No samples overlap. """ + if default_estimated_duration is None: + default_estimated_duration = DEFAULT_ESTIMATED_DURATION + samples.sort(key=lambda x: x.end_at) previous_sample_end = None