* refactor(chalice): upgraded dependencies

* refactor(chalice): upgraded dependencies
feat(chalice): support heatmaps

* 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

* refactor(chalice): upgraded dependencies

* refactor(chalice): upgraded dependencies
feat(chalice): support heatmaps

* 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

* refactor(chalice): upgraded dependencies
refactor(crons): upgraded dependencies
refactor(alerts): upgraded dependencies

* feat(chalice): get top 10 values for autocomplete CH

* refactor(chalice): cleaned code
refactor(chalice): upgraded dependencies
refactor(alerts): upgraded dependencies
refactor(crons): upgraded dependencies

* feat(chalice): autocomplete return top 10 with stats

* fix(chalice): fixed autocomplete top 10 meta-filters

* feat(chalice): table of referrers CH
This commit is contained in:
Kraiem Taha Yassine 2024-08-12 08:23:20 +02:00 committed by GitHub
parent ce75b72226
commit b6e28b9e66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 11 deletions

View file

@ -538,7 +538,8 @@ def delete_card(project_id, metric_id, user_id):
SET deleted_at = timezone('utc'::text, now()), edited_at = timezone('utc'::text, now())
WHERE project_id = %(project_id)s
AND metric_id = %(metric_id)s
AND (user_id = %(user_id)s OR is_public);""",
AND (user_id = %(user_id)s OR is_public)
RETURNING data;""",
{"metric_id": metric_id, "project_id": project_id, "user_id": user_id})
)

View file

@ -157,16 +157,21 @@ def __get_table_of_urls(project_id: int, data: schemas.CardTable, user_id: int =
return __get_table_of_series(project_id=project_id, data=data)
def __get_table_of_referrers(project_id: int, data: schemas.CardTable, user_id: int = None):
return __get_table_of_series(project_id=project_id, data=data)
def __get_table_chart(project_id: int, data: schemas.CardTable, user_id: int):
supported = {
schemas.MetricOfTable.SESSIONS: __get_table_of_sessions,
schemas.MetricOfTable.ERRORS: __get_table_of_errors,
schemas.MetricOfTable.USER_ID: __get_table_of_user_ids,
schemas.MetricOfTable.ISSUES: __get_table_of_issues,
schemas.MetricOfTable.user_browser: __get_table_of_browsers,
schemas.MetricOfTable.USER_BROWSER: __get_table_of_browsers,
schemas.MetricOfTable.USER_DEVICE: __get_table_of_devises,
schemas.MetricOfTable.USER_COUNTRY: __get_table_of_countries,
schemas.MetricOfTable.VISITED_URL: __get_table_of_urls,
schemas.MetricOfTable.REFERRER: __get_table_of_referrers,
}
return supported.get(data.metric_of, not_supported)(project_id=project_id, data=data, user_id=user_id)

View file

@ -400,20 +400,20 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
full_args["limit_e"] = data.page * data.limit
main_col = "user_id"
extra_col = "s.user_id"
extra_col = ", s.user_id"
extra_where = ""
if metric_of == schemas.MetricOfTable.USER_COUNTRY:
main_col = "user_country"
extra_col = "s.user_country"
extra_col = ", s.user_country"
elif metric_of == schemas.MetricOfTable.USER_DEVICE:
main_col = "user_device"
extra_col = "s.user_device"
elif metric_of == schemas.MetricOfTable.user_browser:
extra_col = ", s.user_device"
elif metric_of == schemas.MetricOfTable.USER_BROWSER:
main_col = "user_browser"
extra_col = "s.user_browser"
extra_col = ", s.user_browser"
elif metric_of == schemas.MetricOfTable.ISSUES:
main_col = "issue"
extra_col = f"arrayJoin(s.issue_types) AS {main_col}"
extra_col = f", arrayJoin(s.issue_types) AS {main_col}"
if len(metric_value) > 0:
extra_where = []
for i in range(len(metric_value)):
@ -423,15 +423,17 @@ def search2_table(data: schemas.SessionsSearchPayloadSchema, project_id: int, de
extra_where = f"WHERE ({' OR '.join(extra_where)})"
elif metric_of == schemas.MetricOfTable.VISITED_URL:
main_col = "url_path"
extra_col = "s.url_path"
extra_col = ", s.url_path"
elif metric_of == schemas.MetricOfTable.REFERRER:
main_col = "referrer"
extra_col = ", referrer"
if metric_format == schemas.MetricExtendedFormatType.SESSION_COUNT:
main_query = f"""SELECT COUNT(DISTINCT {main_col}) OVER () AS main_count,
{main_col} AS name,
count(DISTINCT session_id) AS session_count,
COALESCE(SUM(count(DISTINCT session_id)) OVER (), 0) AS total_sessions
FROM (SELECT s.session_id AS session_id,
{extra_col}
FROM (SELECT s.session_id AS session_id {extra_col}
{query_part}) AS filtred_sessions
{extra_where}
GROUP BY {main_col}