fix(chalice): fixed missing totalSessions in card-tables in EE (#2390)

* fix(chalice): fixed missing totalSessions in card-tables in EE

* fix(chalice): fixed missing totalSessions in card-tables in EE

(cherry picked from commit 72afae226b)
This commit is contained in:
Kraiem Taha Yassine 2024-07-16 14:16:26 +02:00 committed by Taha Yassine Kraiem
parent 02454e722e
commit 8c199e6f41

View file

@ -442,7 +442,8 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
if metric_format == schemas.MetricExtendedFormatType.session_count:
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
{main_col} AS name,
count(DISTINCT session_id) AS session_count
count(DISTINCT session_id) AS session_count,
COALESCE(SUM(count(DISTINCT session_id)) OVER (), 0) AS total_sessions
FROM (SELECT s.session_id AS session_id,
{extra_col}
{query_part}) AS filtred_sessions
@ -470,11 +471,14 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
logging.debug("--------------------")
sessions = cur.execute(main_query)
count = 0
total_sessions = 0
if len(sessions) > 0:
count = sessions[0]["main_count"]
total_sessions = sessions[0]["total_sessions"]
for s in sessions:
s.pop("main_count")
sessions = {"count": count, "values": helper.list_to_camel_case(sessions)}
s.pop("total_sessions")
sessions = {"count": count, "totalSessions": total_sessions, "values": helper.list_to_camel_case(sessions)}
return sessions