From 3241585ba6ca57a24b5ed9bcb3e16b3f0b506cf5 Mon Sep 17 00:00:00 2001 From: Hamza Date: Fri, 9 Feb 2024 13:45:44 +0100 Subject: [PATCH] Hotfix/timestamp mismatch for logs (#149) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Viktor Sandström --- apps/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/views.py b/apps/views.py index 4bde4f83..a378b9ee 100644 --- a/apps/views.py +++ b/apps/views.py @@ -89,13 +89,14 @@ def post(self, request, user, project): } res = requests.get(url, params=query) res_json = res.json()["data"]["result"] - + # TODO: change timestamp logic. Timestamps are different in prod and dev for item in res_json: for log_line in reversed(item["values"]): # separate timestamp and log separated_log = log_line[1].split(None, 1) # improve timestamp formatting for table - formatted_time = datetime.strptime(separated_log[0][:-4], "%Y-%m-%dT%H:%M:%S.%f") + filtered_log = separated_log[0][:-4] if settings.DEBUG else separated_log[0][:-10] + formatted_time = datetime.strptime(filtered_log, "%Y-%m-%dT%H:%M:%S.%f") separated_log[0] = datetime.strftime(formatted_time, "%Y-%m-%d, %H:%M:%S") logs.append(separated_log)