From 61f9e8bc04356fba9ef8ce2e8c975d9bde05e80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Mon, 23 Dec 2024 21:38:56 -0300 Subject: [PATCH] full log limited to 200 entries --- utils/statistics_server_v3.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/statistics_server_v3.py b/utils/statistics_server_v3.py index 7d45482..88fb631 100644 --- a/utils/statistics_server_v3.py +++ b/utils/statistics_server_v3.py @@ -395,6 +395,8 @@ def fetch_full_log(): ''' GET request Parameters: 'exchange_name" -> string + + It trims the full log to 200 lines, to avoid sending too much data to the client. ''' if "X-API-KEY" in request.headers and request.headers.get("X-API-KEY") in valid_keys: try: @@ -402,11 +404,11 @@ def fetch_full_log(): width = 0 last_lines,amount_of_lines = last_n_lines(f"../logs/{exchange_name}.log",width,0,full_log=True) if not cache_requests: - return jsonify({"line": last_lines, "amount_of_lines": amount_of_lines}) + return jsonify({"line": last_lines[-200:], "amount_of_lines": amount_of_lines}) response_hash = hash(str({"line": last_lines, "amount_of_lines": amount_of_lines})) if hashes_db["fetch_full_log"]!=response_hash: hashes_db["fetch_full_log"] = response_hash - return jsonify({"line": last_lines, "amount_of_lines": amount_of_lines}) + return jsonify({"line": last_lines[-200:], "amount_of_lines": amount_of_lines}) return jsonify({"no_changes": True}) except Exception as e: print(e)