From 76d228c5973ff04fcbf6acf79f33f092b64299c3 Mon Sep 17 00:00:00 2001 From: Bart Feenstra Date: Fri, 5 Jan 2024 22:55:41 +0000 Subject: [PATCH] Deduplicate person timeline events. (#1133) --- betty/extension/cotton_candy/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/betty/extension/cotton_candy/__init__.py b/betty/extension/cotton_candy/__init__.py index ebced41b7..d0f3d3448 100644 --- a/betty/extension/cotton_candy/__init__.py +++ b/betty/extension/cotton_candy/__init__.py @@ -250,6 +250,15 @@ def _is_person_timeline_presence(presence: Presence) -> bool: def person_timeline_events(person: Person, lifetime_threshold: int) -> Iterable[Event]: + seen = [] + for event in _person_timeline_events(person, lifetime_threshold): + if event in seen: + continue + seen.append(event) + yield event + + +def _person_timeline_events(person: Person, lifetime_threshold: int) -> Iterable[Event]: # Collect all associated events for a person. # Start with the person's own events for which their presence is public. for presence in person.presences: