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

feat: providers list handler #127

Merged
merged 19 commits into from
Feb 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: list product types containing keyword
  • Loading branch information
sbrunato committed Feb 5, 2024
commit ffc6608aedbc1d939440f4daae40955ae5a80fe0
20 changes: 12 additions & 8 deletions eodag_labextension/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,19 @@ def get(self):
and len(query_dict["keywords"]) > 0
):
# 1. List product types starting with given keywords
first_keyword = query_dict["keywords"][0]
returned_product_types = [
pt for pt in all_product_types if pt["ID"].lower().startswith(first_keyword.lower())
]
first_keyword = query_dict["keywords"][0].lower()
returned_product_types = [pt for pt in all_product_types if pt["ID"].lower().startswith(first_keyword)]
returned_product_types_ids = [pt["ID"] for pt in returned_product_types]

# 2. Append guessed product types
# 2. List product types containing keyword
returned_product_types += [
pt
for pt in all_product_types
if first_keyword in pt["ID"].lower() and pt["ID"] not in returned_product_types_ids
]
returned_product_types_ids += [pt["ID"] for pt in returned_product_types]

# 3. Append guessed product types
guess_kwargs = {}
# ["aa bb", "cc-dd_ee"] to "*aa* *bb* *cc* **dd* *ee*"
for k, v in query_dict.items():
Expand All @@ -104,13 +110,11 @@ def get(self):
# guessed product types ids
guessed_ids_list = eodag_api.guess_product_type(**guess_kwargs)
# product types with full associated metadata
guessed_list = [
returned_product_types += [
pt
for pt in all_product_types
if pt["ID"] in guessed_ids_list and pt["ID"] not in returned_product_types_ids
]

returned_product_types += guessed_list
else:
returned_product_types = all_product_types

Expand Down
Loading