From 111dc0db0b56af1627a3e7ca4841d34e01ad99d7 Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Tue, 2 Jul 2024 16:45:36 +0200 Subject: [PATCH] Dev (#2338) * refactor(chalice): upgraded dependencies * refactor(chalice): upgraded dependencies feat(chalice): support heatmaps * feat(chalice): support table-of-browsers showing user-count * feat(chalice): support table-of-devices showing user-count * feat(chalice): support table-of-URLs showing user-count * fix(chalice): fixed Math-operators validation refactor(chalice): search for sessions that have events for heatmaps * refactor(chalice): search for sessions that have at least 1 location event for heatmaps * fix(chalice): fixed card-tableOf pagination --- api/chalicelib/core/sessions.py | 8 +++++++- ee/api/chalicelib/core/sessions_exp.py | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/chalicelib/core/sessions.py b/api/chalicelib/core/sessions.py index 1621c0bb8..f7cfbac37 100644 --- a/api/chalicelib/core/sessions.py +++ b/api/chalicelib/core/sessions.py @@ -329,6 +329,10 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de full_args["step_size"] = step_size with pg_client.PostgresClient() as cur: if isinstance(metric_of, schemas.MetricOfTable): + full_args["limit"] = data.limit + full_args["limit_s"] = (data.page - 1) * data.limit + full_args["limit_e"] = data.page * data.limit + main_col = "user_id" extra_col = "" extra_where = "" @@ -356,7 +360,9 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de if metric_format == schemas.MetricExtendedFormatType.session_count: main_query = f"""SELECT COUNT(*) AS count, COALESCE(SUM(users_sessions.session_count),0) AS total_sessions, - COALESCE(JSONB_AGG(users_sessions) FILTER ( WHERE rn <= 200 ), '[]'::JSONB) AS values + COALESCE(JSONB_AGG(users_sessions) + FILTER ( WHERE rn > %(limit_s)s + AND rn <= %(limit_e)s ), '[]'::JSONB) AS values FROM (SELECT {main_col} AS name, count(DISTINCT session_id) AS session_count, ROW_NUMBER() OVER (ORDER BY count(full_sessions) DESC) AS rn diff --git a/ee/api/chalicelib/core/sessions_exp.py b/ee/api/chalicelib/core/sessions_exp.py index 4dd3f0d13..9b472f08f 100644 --- a/ee/api/chalicelib/core/sessions_exp.py +++ b/ee/api/chalicelib/core/sessions_exp.py @@ -408,9 +408,11 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de full_args["step_size"] = step_size sessions = [] with ch_client.ClickHouseClient() as cur: - full_args["limit_s"] = 0 - full_args["limit_e"] = 200 if isinstance(metric_of, schemas.MetricOfTable): + full_args["limit"] = data.limit + full_args["limit_s"] = (data.page - 1) * data.limit + full_args["limit_e"] = data.page * data.limit + main_col = "user_id" extra_col = "s.user_id" extra_where = ""