Skip to content

Commit

Permalink
Set default values according to the order option
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedElgizery committed Aug 18, 2024
1 parent 889b8c9 commit e4e1e9e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/imagery/i.eodag/i.eodag.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,23 @@ def sort_result(search_result):
sort_keys = list()
for sort_key in options["sort"].split(","):
if sort_key == "ingestiondate":
sort_keys.append(("startTimeFromAscendingNode", "3000-12-31T00:00:00"))
sort_keys.append(
(
"startTimeFromAscendingNode",
(
"3000-12-31T00:00:00"
if options["order"] == "asc"
else "1000-01-01T00:00:00"
),
)
)
if sort_key == "title":
sort_keys.append(("title", "Z" * 100))
sort_keys.append(("title", "Z" * 100 if options["order"] == "asc" else "A"))
if sort_key == "cloudcover":
sort_keys.append(("cloudCover", int(1e9)))
sort_keys.append(
("cloudCover", int(1e9) * 1 if options["order"] == "asc" else -1)
)
# Default values are used to put scenes with missing sorting key at the end
search_result.sort(
reverse=options["order"] == "desc",
key=lambda product: [
Expand Down

0 comments on commit e4e1e9e

Please sign in to comment.