Skip to content

Commit

Permalink
fix(chalice): user-journey reversed hide minor paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Jan 30, 2025
1 parent 0484c0c commit fc4d499
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/chalicelib/core/metrics/product_analytics_ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
top_query = []
top_with_next_query = []
other_query = []
for i in range(1, data.density + (0 if data.hide_excess else 1)):
for i in range(1, data.density + (1 if data.hide_excess else 0)):
steps_query.append(f"""n{i} AS (SELECT event_number_in_session,
`$event_name`,
e_value,
Expand All @@ -356,7 +356,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
WHERE event_number_in_session = {i}
GROUP BY event_number_in_session, `$event_name`, e_value, next_type, next_value
ORDER BY sessions_count DESC)""")
if data.hide_excess:
if not data.hide_excess:
projection_query.append(f"""\
SELECT event_number_in_session,
`$event_name`,
Expand Down Expand Up @@ -386,7 +386,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
sessions_count
FROM n{i}
WHERE isNull(n{i}.next_type)""")
if not data.hide_excess:
if data.hide_excess:
top_with_next_query.append(f"""\
SELECT n{i}.*
FROM n{i}
Expand All @@ -395,7 +395,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
AND n{i}.`$event_name` = top_n.`$event_name`
AND n{i}.e_value = top_n.e_value)""")

if i > 1 and not data.hide_excess:
if i > 1 and data.hide_excess:
other_query.append(f"""SELECT n{i}.*
FROM n{i}
WHERE (event_number_in_session, `$event_name`, e_value) NOT IN
Expand Down Expand Up @@ -463,7 +463,7 @@ def path_analysis(project_id: int, data: schemas.CardPathAnalysis):
_now = time()

sub_cte = ""
if not data.hide_excess:
if data.hide_excess:
sub_cte = f""",
top_n AS ({"\nUNION ALL\n".join(top_query)}),
top_n_with_next AS ({"\nUNION ALL\n".join(top_with_next_query)}),
Expand Down

0 comments on commit fc4d499

Please sign in to comment.