Skip to content

Commit

Permalink
fix: return only user requested item if id is present (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
alambare committed Oct 11, 2023
1 parent 32c2654 commit 5165658
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions eodag/plugins/search/data_request_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ def _convert_result_data(
"""Build EOProducts from provider results"""
results_entry = self.config.results_entry
results = result_data[results_entry]
normalize_remaining_count = len(results)
logger.debug(
"Adapting %s plugin results to eodag product representation"
% normalize_remaining_count
"Adapting %s plugin results to eodag product representation" % len(results)
)
products = []
for result in results:
Expand All @@ -338,11 +336,16 @@ def _convert_result_data(
getattr(self.config, "product_type_config", {}), **product.properties
)
products.append(product)
# postprocess filtering needed when provider does not natively offer filtering by id
if "id" in kwargs:
products = [
p for p in products if product.properties["id"] == kwargs["id"]
] or products
total_items_nb_key_path = string_to_jsonpath(
self.config.pagination["total_items_nb_key_path"]
)
if len(total_items_nb_key_path.find(result_data)) > 0:
total_items_nb = total_items_nb_key_path.find(result_data)[0].value
if len(total_items_nb_key_path.find(results)) > 0:
total_items_nb = total_items_nb_key_path.find(results)[0].value
else:
total_items_nb = 0
for p in products:
Expand Down

0 comments on commit 5165658

Please sign in to comment.