Skip to content

Commit

Permalink
feat(chalice): autocomplete return top 10 with stats
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Aug 2, 2024
1 parent ae720f5 commit 4b8788d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions api/chalicelib/core/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,9 @@ def get_top_values(project_id, event_type, event_key=None):
query = f"""WITH raw AS (SELECT DISTINCT {colname} AS c_value,
COUNT(1) OVER (PARTITION BY {colname}) AS row_count,
COUNT(1) OVER () AS total_count
FROM public.sessions
FROM experimental.sessions
WHERE project_id = %(project_id)s
AND {colname} IS NOT NULL
AND sessions.duration IS NOT NULL
AND sessions.duration > 0
ORDER BY row_count DESC
LIMIT 10)
SELECT c_value AS value, row_count, trunc(row_count * 100 / total_count, 2) AS row_percentage
Expand Down

0 comments on commit 4b8788d

Please sign in to comment.