From b690ffc51c16a78f5fdea27e05f58c610679fd43 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 16 Mar 2025 22:00:51 +0100 Subject: [PATCH] Fixed activity --- personal_data/activity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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