From 2bc16a708c3ff56c382944223a57a55f56184cea Mon Sep 17 00:00:00 2001 From: Cyril NOVEL <5690282+cnovel@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:58:07 +0100 Subject: [PATCH] Fix find SO --- src/event.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/event.py b/src/event.py index 505fdcb..fc260c5 100644 --- a/src/event.py +++ b/src/event.py @@ -144,10 +144,10 @@ def load_mariage_to_list(mariages_file: str) -> list: def find_significant_other(mariages: list, uid: int) -> (int, str): - for m in mariages: - if m.in_this_union(uid): - return m.get_so(uid), m.union() - return -1, '' + matches = sorted([m for m in mariages if m.in_this_union(uid)], key=lambda union: union.event_date()) + if not matches: + return -1, '' + return matches[-1].get_so(uid), matches[-1].union() def create_events_from_span(start: date, end: date, id_to_person: dict, mariages: list) -> list: