Commit 49e8cd67 authored by OWAIZ MUSTAFA KHAN's avatar OWAIZ MUSTAFA KHAN 😎

Bugfix: Formating index info to readable data

parent eebb6b5e
.venv
.idea
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
\ No newline at end of file
......@@ -81,7 +81,7 @@ def delete_index_not_in_db(payload: DeleteIndexNotInDB):
collections_info = list(metadata_collection.find({}, {'_id': 0}))
for collection_info in collections_info:
index_infos = get_index_info(collection_info)
index_infos = get_index_info(collection_info, for_delete = True)
collection = get_collection(
collection_info.get(
......
......@@ -61,7 +61,7 @@ def get_collection_info(index: dict):
db_name = index.get('database', index.get('db', index.get('db_name')))
return collection_name, db_name
def get_index_info(collection_info: dict) -> list[dict]:
def get_index_info(collection_info: dict, for_delete: bool = False) -> list[dict]:
collection_name, db_name = get_collection_info(collection_info)
collection = get_collection(collection_name, db_name)
......@@ -71,7 +71,7 @@ def get_index_info(collection_info: dict) -> list[dict]:
# Format to readable data
index_infos = [
{"name": idx["name"], "fields": [[k, 1 if v == 'ASC' else 'DESC'] for k, v in idx["key"].items()]}
{"name": idx["name"], "fields": [[k, ('ASC' if v == 1 else 'DESC') if for_delete else (1 if v == 'ASC' else -1)] for k, v in idx["key"].items()]}
for idx in add_index_list
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment