From 86ff96816ac2edacddef98ce234e3d40ee4fa38d Mon Sep 17 00:00:00 2001 From: Georges Haddad Date: Wed, 15 Apr 2026 10:29:41 +0300 Subject: [PATCH] Fix merge not working for candidates with no scope or All Lebanon scope --- routers/review.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/routers/review.py b/routers/review.py index aceea5a..002303a 100644 --- a/routers/review.py +++ b/routers/review.py @@ -233,8 +233,19 @@ def _get_merge_candidates( if normalized_father and person.get("father_name"): if normalize_arabic(person["father_name"]) != normalized_father: continue + scope_values = [_normalize_scope(s) or s.strip() for s in (person.get("search_scopes") or "").split(",") if s.strip()] - same_scope = bool(normalized_scope and normalized_scope in scope_values) + + same_scope = False + if not normalized_scope: + same_scope = True + elif not scope_values: + same_scope = True + elif normalized_scope == "كل لبنان" or "كل لبنان" in scope_values or _normalize_scope("كل لبنان") in scope_values: + same_scope = True + elif normalized_scope in scope_values: + same_scope = True + registry_match = bool( normalized_registry and person.get("registry_number")