From 7c88ff1d1128c64d37deefcb8c5e5a232646b1da Mon Sep 17 00:00:00 2001 From: victor barbier Date: Mon, 9 Sep 2024 12:12:26 +0200 Subject: [PATCH] fix(matcher): clean highlight and debug --- project/server/main/matcher.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/project/server/main/matcher.py b/project/server/main/matcher.py index 25662ad..42559a8 100644 --- a/project/server/main/matcher.py +++ b/project/server/main/matcher.py @@ -157,11 +157,11 @@ def clean_highlights(highlights: dict): for criteria in highlights[strategy][match_id]: if criteria not in new_highlights[match_id]["criterion"]: new_highlights[match_id]["criterion"][criteria] = [] - for highlight in highlights[strategy][match_id][criteria]: - logger.debug(f"highlight: {highlight}") - new_highlights[match_id]["criterion"][criteria] = [ - tag.text for tag in BeautifulSoup(highlight[0], "lxml").find_all("em") - ] + for highlight in highlights[strategy][match_id][criteria]: + logger.debug(f"highlight: {highlight}") + new_highlights[match_id]["criterion"][criteria].append( + [tag.text for tag in BeautifulSoup(highlight[0], "lxml").find_all("em")] + ) return new_highlights @@ -271,9 +271,9 @@ def match(self, method: str = None, conditions: dict = None, strategies: list = logs += f'Strategy : {strategy} : {len(strategy_results)} matches
' logs += f'Equivalent strategies have {len(equivalent_strategies_results)} possibilities that match ' \ f'one of the strategy
' - debug["strategies"].append( - {"equivalent_strategies": equivalent_strategies, "matches": len(equivalent_strategies_results)} - ) + debug["strategies"].append( + {"equivalent_strategies": equivalent_strategies, "matches": len(equivalent_strategies_results)} + ) # Strategies stopped as soon as a first result is met for an equivalent_strategies all_highlights = {} if len(equivalent_strategies_results) > 0: