From bb21df8b5fafc9402e257d4eeed5b5e54953ba68 Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Fri, 8 Jul 2022 17:46:58 +0200 Subject: [PATCH] v1.7.0 hot fixes feat(api): fixed resources read time (#585) feat(api): changed resources read time delta --- api/chalicelib/core/resources.py | 5 +++-- ee/api/chalicelib/core/resources.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/chalicelib/core/resources.py b/api/chalicelib/core/resources.py index 1e2f4718e..11c07e854 100644 --- a/api/chalicelib/core/resources.py +++ b/api/chalicelib/core/resources.py @@ -4,7 +4,7 @@ from decouple import config def get_by_session_id(session_id, project_id, start_ts, duration): with pg_client.PostgresClient() as cur: - delta = config("events_ts_delta", cast=int, default=5 * 60) * 1000 + delta = config("events_ts_delta", cast=int, default=60 * 60) * 1000 ch_query = """\ SELECT timestamp AS datetime, @@ -22,9 +22,10 @@ def get_by_session_id(session_id, project_id, start_ts, duration): AND project_id= %(project_id)s AND sessions.start_ts=%(start_ts)s AND resources.timestamp>=%(res_start_ts)s - AND resources.timestamp>=%(res_end_ts)s;""" + AND resources.timestamp<=%(res_end_ts)s;""" params = {"session_id": session_id, "project_id": project_id, "start_ts": start_ts, "duration": duration, "res_start_ts": start_ts - delta, "res_end_ts": start_ts + duration + delta, } + print(cur.mogrify(ch_query, params)) cur.execute(cur.mogrify(ch_query, params)) rows = cur.fetchall() return helper.list_to_camel_case(rows) diff --git a/ee/api/chalicelib/core/resources.py b/ee/api/chalicelib/core/resources.py index 7666e66cf..a1f966937 100644 --- a/ee/api/chalicelib/core/resources.py +++ b/ee/api/chalicelib/core/resources.py @@ -6,7 +6,7 @@ from decouple import config def get_by_session_id(session_id, project_id, start_ts, duration): with ch_client.ClickHouseClient() as ch: - delta = config("events_ts_delta", cast=int, default=5 * 60) * 1000 + delta = config("events_ts_delta", cast=int, default=60 * 60) * 1000 ch_query = """\ SELECT datetime,url,type,duration,ttfb,header_size,encoded_body_size,decoded_body_size,success,coalesce(status,if(success, 200, status)) AS status