diff --git a/api/chalicelib/core/errors.py b/api/chalicelib/core/errors.py index a10a14ad1..2a9a299da 100644 --- a/api/chalicelib/core/errors.py +++ b/api/chalicelib/core/errors.py @@ -251,10 +251,7 @@ def get_details(project_id, error_id, user_id, **data): parent_error_id,session_id, user_anonymous_id, user_id, user_uuid, user_browser, user_browser_version, user_os, user_os_version, user_device, payload, - COALESCE((SELECT TRUE - FROM public.user_favorite_errors AS fe - WHERE pe.error_id = fe.error_id - AND fe.user_id = %(user_id)s), FALSE) AS favorite, + FALSE AS favorite, True AS viewed FROM public.errors AS pe INNER JOIN events.errors AS ee USING (error_id) @@ -488,9 +485,9 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): if error_ids is not None: params["error_ids"] = tuple(error_ids) pg_sub_query.append("error_id IN %(error_ids)s") - if data.bookmarked: - pg_sub_query.append("ufe.user_id = %(userId)s") - extra_join += " INNER JOIN public.user_favorite_errors AS ufe USING (error_id)" + # if data.bookmarked: + # pg_sub_query.append("ufe.user_id = %(userId)s") + # extra_join += " INNER JOIN public.user_favorite_errors AS ufe USING (error_id)" if data.query is not None and len(data.query) > 0: pg_sub_query.append("(pe.name ILIKE %(error_query)s OR pe.message ILIKE %(error_query)s)") params["error_query"] = helper.values_for_operator(value=data.query, @@ -553,10 +550,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): if len(statuses) == 0: query = cur.mogrify( """SELECT error_id, status, parent_error_id, payload, - COALESCE((SELECT TRUE - FROM public.user_favorite_errors AS fe - WHERE errors.error_id = fe.error_id - AND fe.user_id = %(user_id)s LIMIT 1), FALSE) AS favorite, + FALSE AS favorite, COALESCE((SELECT TRUE FROM public.user_viewed_errors AS ve WHERE errors.error_id = ve.error_id diff --git a/ee/api/chalicelib/core/errors.py b/ee/api/chalicelib/core/errors.py index 07a5e10ba..f7cb40436 100644 --- a/ee/api/chalicelib/core/errors.py +++ b/ee/api/chalicelib/core/errors.py @@ -263,10 +263,7 @@ def get_details(project_id, error_id, user_id, **data): parent_error_id,session_id, user_anonymous_id, user_id, user_uuid, user_browser, user_browser_version, user_os, user_os_version, user_device, payload, - COALESCE((SELECT TRUE - FROM public.user_favorite_errors AS fe - WHERE pe.error_id = fe.error_id - AND fe.user_id = %(userId)s), FALSE) AS favorite, + FALSE AS favorite, True AS viewed FROM public.errors AS pe INNER JOIN events.errors AS ee USING (error_id) @@ -529,9 +526,9 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): if error_ids is not None: params["error_ids"] = tuple(error_ids) pg_sub_query.append("error_id IN %(error_ids)s") - if data.bookmarked: - pg_sub_query.append("ufe.user_id = %(userId)s") - extra_join += " INNER JOIN public.user_favorite_errors AS ufe USING (error_id)" + # if data.bookmarked: + # pg_sub_query.append("ufe.user_id = %(userId)s") + # extra_join += " INNER JOIN public.user_favorite_errors AS ufe USING (error_id)" if data.query is not None and len(data.query) > 0: pg_sub_query.append("(pe.name ILIKE %(error_query)s OR pe.message ILIKE %(error_query)s)") params["error_query"] = helper.values_for_operator(value=data.query, @@ -594,10 +591,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): if len(statuses) == 0: query = cur.mogrify( """SELECT error_id, status, parent_error_id, payload, - COALESCE((SELECT TRUE - FROM public.user_favorite_errors AS fe - WHERE errors.error_id = fe.error_id - AND fe.user_id = %(user_id)s LIMIT 1), FALSE) AS favorite, + FALSE AS favorite, COALESCE((SELECT TRUE FROM public.user_viewed_errors AS ve WHERE errors.error_id = ve.error_id @@ -692,16 +686,16 @@ def search_deprecated(data: schemas.SearchErrorsSchema, project_id, user_id, flo else: params["errors_offset"] = 0 params["errors_limit"] = 200 - if data.bookmarked: - cur.execute(cur.mogrify(f"""SELECT error_id - FROM public.user_favorite_errors - WHERE user_id = %(userId)s - {"" if error_ids is None else "AND error_id IN %(error_ids)s"}""", - {"userId": user_id, "error_ids": tuple(error_ids or [])})) - error_ids = cur.fetchall() - if len(error_ids) == 0: - return empty_response - error_ids = [e["error_id"] for e in error_ids] + # if data.bookmarked: + # cur.execute(cur.mogrify(f"""SELECT error_id + # FROM public.user_favorite_errors + # WHERE user_id = %(userId)s + # {"" if error_ids is None else "AND error_id IN %(error_ids)s"}""", + # {"userId": user_id, "error_ids": tuple(error_ids or [])})) + # error_ids = cur.fetchall() + # if len(error_ids) == 0: + # return empty_response + # error_ids = [e["error_id"] for e in error_ids] if error_ids is not None: params["error_ids"] = tuple(error_ids) @@ -755,10 +749,7 @@ def search_deprecated(data: schemas.SearchErrorsSchema, project_id, user_id, flo if len(statuses) == 0: query = cur.mogrify( """SELECT error_id, status, parent_error_id, payload, - COALESCE((SELECT TRUE - FROM public.user_favorite_errors AS fe - WHERE errors.error_id = fe.error_id - AND fe.user_id = %(userId)s LIMIT 1), FALSE) AS favorite, + FALSE AS favorite, COALESCE((SELECT TRUE FROM public.user_viewed_errors AS ve WHERE errors.error_id = ve.error_id