Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 16 additions & 16 deletions cumulus_lambda_functions/uds_api/dapa/granules_dapa_query_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ def get_sorting_arguments(self):
{'properties.datetime': {'order': 'desc'}},
{'id': {'order': 'asc'}}
]
sorting_dict = {}
sort_keys = [k.strip() for k in self.__sort_by.split(',')]
sort_key_set = set()
sort_keys_dsl = []
for each_key in sort_keys:
if each_key.startswith('+'):
sorting_dict[each_key[1:]] = {'order': 'asc'}
current_sort_key = each_key[1:]
current_sort_dict = {current_sort_key: {'order': 'asc'}}
elif each_key.startswith('-'):
sorting_dict[each_key[1:]] = {'order': 'desc'}
current_sort_key = each_key[1:]
current_sort_dict = {current_sort_key: {'order': 'desc'}}
else:
sorting_dict[each_key] = {'order': 'asc'}
if 'properties.datetime' not in sorting_dict:
sorting_dict['properties.datetime'] = {'order': 'desc'}
if 'id' not in sorting_dict:
sorting_dict['id'] = {'order': 'asc'}

sorting_array = [
{'properties.datetime': sorting_dict.pop('properties.datetime')},
{'id': sorting_dict.pop('id')},
]
for k, v in sorting_dict.items():
sorting_array.append({k: v})
return sorting_array
current_sort_key = each_key
current_sort_dict = {current_sort_key: {'order': 'asc'}}
if current_sort_key not in sort_key_set:
sort_keys_dsl.append(current_sort_dict)
sort_key_set.add(current_sort_key)
if 'properties.datetime' not in sort_key_set:
sort_keys_dsl.append({'properties.datetime': {'order': 'desc'}})
if 'id' not in sort_key_set:
sort_keys_dsl.append({'id': {'order': 'asc'}})
return sort_keys_dsl

def __generate_es_dsl(self):
query_terms = []
Expand Down
3 changes: 2 additions & 1 deletion cumulus_lambda_functions/uds_api/routes_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi import APIRouter

from cumulus_lambda_functions.uds_api import collections_api, granules_api, auth_admin_api, system_admin_api, \
custom_meta_admin_api, catalog_api, misc_api
custom_meta_admin_api, catalog_api, misc_api, granules_archive_api

# from ideas_api.src.endpoints import job_endpoints
# from ideas_api.src.endpoints import process_endpoints
Expand All @@ -15,6 +15,7 @@
main_router.include_router(collections_api.router)
main_router.include_router(catalog_api.router)
main_router.include_router(granules_api.router)
main_router.include_router(granules_archive_api.router)
main_router.include_router(custom_meta_admin_api.router)
main_router.include_router(misc_api.router)

Loading