From 0254ee108889a2ab682681e212e25b3e5d7fc1ef Mon Sep 17 00:00:00 2001 From: TeachMeTW Date: Mon, 9 Dec 2024 12:42:29 -0800 Subject: [PATCH 1/2] fix(db): allow `DB_RESULT_LIMIT` to be set as an integer Previously, `DB_RESULT_LIMIT` was treated as a string, preventing it from being set dynamically. This update ensures it is parsed as an integer, fixing the issue. Updated logic: `result_limit = int(config.get("DB_RESULT_LIMIT", 250000))`. --- emission/core/get_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emission/core/get_database.py b/emission/core/get_database.py index 898973504..7abcf2f84 100644 --- a/emission/core/get_database.py +++ b/emission/core/get_database.py @@ -23,7 +23,7 @@ db_config[key] = None print("Retrieved config: %s" % db_config) url = config.get("DB_HOST", "localhost") -result_limit = config.get("DB_RESULT_LIMIT", 250000) +result_limit = int(config.get("DB_RESULT_LIMIT", 250000)) try: parsed=pymongo.uri_parser.parse_uri(url) From c09665e79cffa7c0e19359e21ca795ad953c0ea7 Mon Sep 17 00:00:00 2001 From: TeachMeTW Date: Mon, 9 Dec 2024 12:54:38 -0800 Subject: [PATCH 2/2] Added exception handling --- emission/core/get_database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emission/core/get_database.py b/emission/core/get_database.py index 7abcf2f84..1f3db4964 100644 --- a/emission/core/get_database.py +++ b/emission/core/get_database.py @@ -23,7 +23,10 @@ db_config[key] = None print("Retrieved config: %s" % db_config) url = config.get("DB_HOST", "localhost") -result_limit = int(config.get("DB_RESULT_LIMIT", 250000)) +try: + result_limit = int(config.get("DB_RESULT_LIMIT", 250000)) +except ValueError: + result_limit = 250000 try: parsed=pymongo.uri_parser.parse_uri(url)