fix(chalice): fixed total-sessions and total-users count for all table cards in CH
This commit is contained in:
parent
4581c29d9d
commit
15b1e6c767
1 changed files with 8 additions and 4 deletions
|
|
@ -240,8 +240,10 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
|
||||||
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
|
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
|
||||||
{main_col} AS name,
|
{main_col} AS name,
|
||||||
count(DISTINCT session_id) AS total,
|
count(DISTINCT session_id) AS total,
|
||||||
COALESCE(SUM(count(DISTINCT session_id)) OVER (), 0) AS total_count
|
any(total_count) as total_count
|
||||||
FROM (SELECT s.session_id AS session_id {extra_col}
|
FROM (SELECT s.session_id AS session_id,
|
||||||
|
count(DISTINCT s.session_id) OVER () AS total_count
|
||||||
|
{extra_col}
|
||||||
{query_part}) AS filtred_sessions
|
{query_part}) AS filtred_sessions
|
||||||
{extra_where}
|
{extra_where}
|
||||||
GROUP BY {main_col}
|
GROUP BY {main_col}
|
||||||
|
|
@ -251,8 +253,10 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
|
||||||
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
|
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
|
||||||
{main_col} AS name,
|
{main_col} AS name,
|
||||||
count(DISTINCT user_id) AS total,
|
count(DISTINCT user_id) AS total,
|
||||||
COALESCE(SUM(count(DISTINCT user_id)) OVER (), 0) AS total_count
|
any(total_count) AS total_count
|
||||||
FROM (SELECT s.user_id AS user_id {extra_col}
|
FROM (SELECT s.user_id AS user_id,
|
||||||
|
count(DISTINCT s.user_id) OVER () AS total_count
|
||||||
|
{extra_col}
|
||||||
{query_part}
|
{query_part}
|
||||||
WHERE isNotNull(user_id)
|
WHERE isNotNull(user_id)
|
||||||
AND notEmpty(user_id)) AS filtred_sessions
|
AND notEmpty(user_id)) AS filtred_sessions
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue