Skip to content

Commit

Permalink
Merge results from the same URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Jan 8, 2024
1 parent 6591c7f commit e9bbe44
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions geotribu_cli/search/search_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def run(args: argparse.Namespace):

# résultats : enrichissement et filtre
count_ignored_results = 0
unique_ref: list = []
with console.status(
f"Enrichissement des {len(search_results)} résultats...", spinner="earth"
):
Expand Down Expand Up @@ -390,6 +391,21 @@ def run(args: argparse.Namespace):
count_ignored_results += 1
continue

if (
result.get("ref").startswith("articles/")
and "#" in result.get("ref")
and result.get("ref").split("#")[0] in unique_ref
):
logger.info(
f"Résultat {result.get('ref')} ignoré car il s'agit d'une "
f"sous-partie ({result.get('ref').split('#')[1]}) d'un article déjà "
"présent dans les résultats."
)
count_ignored_results += 1
continue

unique_ref.append(result.get("ref").split("#")[0])

# crée un résultat de sortie
out_result = {
"type": "Article"
Expand Down

0 comments on commit e9bbe44

Please sign in to comment.