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

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

* fix(chalice): fixed view error code
This commit is contained in:
Kraiem Taha Yassine 2024-12-23 18:46:56 +01:00 committed by GitHub
parent 82ab91bc25
commit 7b7856184e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 17 deletions

View file

@ -4,9 +4,10 @@ from decouple import config
logger = logging.getLogger(__name__)
from . import errors as errors_legacy
if config("EXP_ERRORS_SEARCH", cast=bool, default=False):
logger.info(">>> Using experimental error search")
from . import errors as errors_legacy
from . import errors_ch as errors
else:
from . import errors

View file

@ -204,11 +204,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
else:
if len(statuses) == 0:
query = cur.mogrify(
"""SELECT error_id,
COALESCE((SELECT TRUE
FROM public.user_viewed_errors AS ve
WHERE errors.error_id = ve.error_id
AND ve.user_id = %(user_id)s LIMIT 1), FALSE) AS viewed
"""SELECT error_id
FROM public.errors
WHERE project_id = %(project_id)s AND error_id IN %(error_ids)s;""",
{"project_id": project_id, "error_ids": tuple([r["error_id"] for r in rows]),
@ -221,10 +217,6 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
for r in rows:
r.pop("full_count")
if r["error_id"] in statuses:
r["viewed"] = statuses[r["error_id"]]["viewed"]
else:
r["viewed"] = False
return {
'total': total,

View file

@ -339,7 +339,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
main_ch_query = f"""\
SELECT details.error_id AS error_id,
name, message, users, total, viewed,
name, message, users, total,
sessions, last_occurrence, first_occurrence, chart
FROM (SELECT error_id,
name,
@ -348,13 +348,8 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id):
COUNT(DISTINCT events.session_id) AS sessions,
MAX(datetime) AS max_datetime,
MIN(datetime) AS min_datetime,
COUNT(DISTINCT events.error_id) OVER() AS total,
any(isNotNull(viewed_error_id)) AS viewed
COUNT(DISTINCT events.error_id) OVER() AS total
FROM {MAIN_EVENTS_TABLE} AS events
LEFT JOIN (SELECT error_id AS viewed_error_id
FROM {exp_ch_helper.get_user_viewed_errors_table()}
WHERE project_id=%(project_id)s
AND user_id=%(userId)s) AS viewed_errors ON(events.error_id=viewed_errors.viewed_error_id)
INNER JOIN (SELECT session_id, coalesce(user_id,toString(user_uuid)) AS user_id
FROM {MAIN_SESSIONS_TABLE} AS s
{subquery_part}