feat(chalice): error-tags

This commit is contained in:
Taha Yassine Kraiem 2022-10-03 16:50:58 +02:00
parent 4a66d36416
commit 66126924b7
5 changed files with 45 additions and 2 deletions

View file

@ -121,7 +121,8 @@ def get_details(project_id, error_id, user_id, **data):
device_partition,
country_partition,
chart24,
chart30
chart30,
tags AS custom_tags
FROM (SELECT error_id,
name,
message,
@ -234,7 +235,10 @@ def get_details(project_id, error_id, user_id, **data):
WHERE {" AND ".join(pg_sub_query30)}) AS chart_details
ON (TRUE)
GROUP BY timestamp
ORDER BY timestamp) AS chart_details) AS chart_details30 ON (TRUE);
ORDER BY timestamp) AS chart_details) AS chart_details30 ON (TRUE)
LEFT JOIN (SELECT jsonb_agg(jsonb_build_object(errors_tags.key, errors_tags.value))
FROM errors_tags INNER JOIN errors USING(error_id)
WHERE {" AND ".join(pg_basic_query)}) AS raw_tags(tags) ON (TRUE);
"""
# print("--------------------")

View file

@ -22,4 +22,14 @@ CREATE TABLE IF NOT EXISTS sessions_notes
is_public boolean NOT NULL DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS errors_tags
(
key text NOT NULL,
value text NOT NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
COMMIT;

View file

@ -497,6 +497,16 @@ $$
CREATE INDEX IF NOT EXISTS user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id);
CREATE INDEX IF NOT EXISTS user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id);
CREATE TABLE IF NOT EXISTS errors_tags
(
key text NOT NULL,
value text NOT NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
IF NOT EXISTS(SELECT *
FROM pg_type typ
WHERE typ.typname = 'platform') THEN

View file

@ -22,4 +22,14 @@ CREATE TABLE IF NOT EXISTS sessions_notes
is_public boolean NOT NULL DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS errors_tags
(
key text NOT NULL,
value text NOT NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id);
COMMIT;

View file

@ -404,6 +404,15 @@ $$
CREATE INDEX user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id);
CREATE INDEX user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id);
CREATE TABLE errors_tags
(
key text NOT NULL,
value text NOT NULL,
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE
);
CREATE INDEX errors_tags_error_id_idx ON errors_tags (error_id);
-- --- sessions.sql ---
CREATE TYPE device_type AS ENUM ('desktop', 'tablet', 'mobile', 'other');