diff --git a/api/Dockerfile b/api/Dockerfile index a8d6210a0..780518ff3 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9.7-slim +FROM python:3.9.10-slim LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" WORKDIR /work diff --git a/api/Dockerfile.alerts b/api/Dockerfile.alerts index 7bff6a9dc..ed8f06eac 100644 --- a/api/Dockerfile.alerts +++ b/api/Dockerfile.alerts @@ -1,4 +1,4 @@ -FROM python:3.9.7-slim +FROM python:3.9.10-slim LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" WORKDIR /work diff --git a/api/Dockerfile.bundle b/api/Dockerfile.bundle index a1577d8c3..e5ccd23f6 100644 --- a/api/Dockerfile.bundle +++ b/api/Dockerfile.bundle @@ -1,4 +1,4 @@ -FROM python:3.9.7-slim +FROM python:3.9.10-slim LABEL Maintainer="Rajesh Rajendran" WORKDIR /work COPY . . diff --git a/api/chalicelib/core/errors.py b/api/chalicelib/core/errors.py index 2bd4a8d80..48e6b7bd9 100644 --- a/api/chalicelib/core/errors.py +++ b/api/chalicelib/core/errors.py @@ -754,22 +754,20 @@ def format_first_stack_frame(error): def stats(project_id, user_id, startTimestamp=TimeUTC.now(delta_days=-7), endTimestamp=TimeUTC.now()): with pg_client.PostgresClient() as cur: query = cur.mogrify( - """ - SELECT COUNT(errors.*) AS unresolved_and_unviewed - FROM public.errors - INNER JOIN (SELECT root_error.error_id - FROM events.errors - INNER JOIN public.errors AS root_error USING (error_id) - WHERE project_id = %(project_id)s - AND timestamp >= %(startTimestamp)s - AND timestamp <= %(endTimestamp)s - AND source = 'js_exception') AS timed_errors USING (error_id) - LEFT JOIN (SELECT error_id FROM public.user_viewed_errors WHERE user_id = %(user_id)s) AS user_viewed - USING (error_id) - WHERE user_viewed.error_id ISNULL - AND errors.project_id = %(project_id)s - AND errors.status = 'unresolved' - AND errors.source = 'js_exception';""", + """WITH user_viewed AS (SELECT error_id FROM public.user_viewed_errors WHERE user_id = %(user_id)s) + SELECT COUNT(timed_errors.*) AS unresolved_and_unviewed + FROM (SELECT root_error.error_id + FROM events.errors + INNER JOIN public.errors AS root_error USING (error_id) + LEFT JOIN user_viewed USING (error_id) + WHERE project_id = %(project_id)s + AND timestamp >= %(startTimestamp)s + AND timestamp <= %(endTimestamp)s + AND source = 'js_exception' + AND root_error.status = 'unresolved' + AND user_viewed.error_id ISNULL + LIMIT 1 + ) AS timed_errors;""", {"project_id": project_id, "user_id": user_id, "startTimestamp": startTimestamp, "endTimestamp": endTimestamp}) cur.execute(query=query) @@ -777,4 +775,4 @@ def stats(project_id, user_id, startTimestamp=TimeUTC.now(delta_days=-7), endTim return { "data": helper.dict_to_camel_case(row) - } \ No newline at end of file + } diff --git a/ee/api/Dockerfile b/ee/api/Dockerfile index 284d752ff..cca6e6806 100644 --- a/ee/api/Dockerfile +++ b/ee/api/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9.7-slim +FROM python:3.9.10-slim LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" RUN apt-get update && apt-get install -y pkg-config libxmlsec1-dev gcc && rm -rf /var/lib/apt/lists/* diff --git a/ee/api/Dockerfile.alerts b/ee/api/Dockerfile.alerts index 5809de5e6..9be6ebc93 100644 --- a/ee/api/Dockerfile.alerts +++ b/ee/api/Dockerfile.alerts @@ -1,4 +1,4 @@ -FROM python:3.9.7-slim +FROM python:3.9.10-slim LABEL Maintainer="Rajesh Rajendran" LABEL Maintainer="KRAIEM Taha Yassine" RUN apt-get update && apt-get install -y pkg-config libxmlsec1-dev gcc && rm -rf /var/lib/apt/lists/* diff --git a/ee/api/chalicelib/core/errors.py b/ee/api/chalicelib/core/errors.py index b25efee7b..04efdbb32 100644 --- a/ee/api/chalicelib/core/errors.py +++ b/ee/api/chalicelib/core/errors.py @@ -766,22 +766,20 @@ def format_first_stack_frame(error): def stats(project_id, user_id, startTimestamp=TimeUTC.now(delta_days=-7), endTimestamp=TimeUTC.now()): with pg_client.PostgresClient() as cur: query = cur.mogrify( - """ - SELECT COUNT(errors.*) AS unresolved_and_unviewed - FROM public.errors - INNER JOIN (SELECT root_error.error_id - FROM events.errors - INNER JOIN public.errors AS root_error USING (error_id) - WHERE project_id = %(project_id)s - AND timestamp >= %(startTimestamp)s - AND timestamp <= %(endTimestamp)s - AND source = 'js_exception') AS timed_errors USING (error_id) - LEFT JOIN (SELECT error_id FROM public.user_viewed_errors WHERE user_id = %(user_id)s) AS user_viewed - USING (error_id) - WHERE user_viewed.error_id ISNULL - AND errors.project_id = %(project_id)s - AND errors.status = 'unresolved' - AND errors.source = 'js_exception';""", + """WITH user_viewed AS (SELECT error_id FROM public.user_viewed_errors WHERE user_id = %(user_id)s) + SELECT COUNT(timed_errors.*) AS unresolved_and_unviewed + FROM (SELECT root_error.error_id + FROM events.errors + INNER JOIN public.errors AS root_error USING (error_id) + LEFT JOIN user_viewed USING (error_id) + WHERE project_id = %(project_id)s + AND timestamp >= %(startTimestamp)s + AND timestamp <= %(endTimestamp)s + AND source = 'js_exception' + AND root_error.status = 'unresolved' + AND user_viewed.error_id ISNULL + LIMIT 1 + ) AS timed_errors;""", {"project_id": project_id, "user_id": user_id, "startTimestamp": startTimestamp, "endTimestamp": endTimestamp}) cur.execute(query=query)