Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return only user requested DataRequestSearch item if id is present #856

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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