From 1d5e07080e6ee0dc14ccad83be10e056875d1427 Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Thu, 9 Nov 2023 18:40:44 +0100 Subject: [PATCH] Api v1.15.0 (#1637) * fix(chalice): fixed path-analysis's density support --- api/chalicelib/core/product_analytics.py | 5 +++-- ee/api/chalicelib/core/product_analytics.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/chalicelib/core/product_analytics.py b/api/chalicelib/core/product_analytics.py index fa8c56640..3a48170d3 100644 --- a/api/chalicelib/core/product_analytics.py +++ b/api/chalicelib/core/product_analytics.py @@ -349,7 +349,8 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis): sessions_count, avg_time_from_previous FROM n1)"""] - for i in range(2, data.density): + + for i in range(2, data.density + 1): steps_query.append(f"""n{i} AS (SELECT * FROM (SELECT re.event_number_in_session, re.event_type, @@ -388,7 +389,7 @@ WITH sub_sessions AS (SELECT session_id {sub_sessions_extra_projection} row_number() OVER (PARTITION BY session_id ORDER BY timestamp {path_direction}) AS event_number_in_session FROM sub_events ORDER BY session_id) AS full_ranked_events - WHERE event_number_in_session < %(density)s), + WHERE event_number_in_session <= %(density)s), start_points AS (SELECT session_id FROM {start_points_from} WHERE {" AND ".join(start_points_conditions)}), diff --git a/ee/api/chalicelib/core/product_analytics.py b/ee/api/chalicelib/core/product_analytics.py index 9f1a5b29d..31fccccd9 100644 --- a/ee/api/chalicelib/core/product_analytics.py +++ b/ee/api/chalicelib/core/product_analytics.py @@ -382,7 +382,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis): sessions_count, avg_time_from_previous FROM n1"""] - for i in range(2, data.density): + for i in range(2, data.density + 1): steps_query.append(f"""n{i} AS (SELECT * FROM (SELECT re.event_number_in_session AS event_number_in_session, re.event_type AS event_type, @@ -428,7 +428,7 @@ WITH {initial_event_cte} FROM {main_table} WHERE {" AND ".join(ch_sub_query)} ) AS full_ranked_events - WHERE event_number_in_session < 4) + WHERE event_number_in_session <= %(density)s) SELECT * FROM pre_ranked_events;""" ch.execute(query=ch_query1, params=params)