diff --git a/api/chalicelib/core/errors.py b/api/chalicelib/core/errors.py index b20853646..85e063f74 100644 --- a/api/chalicelib/core/errors.py +++ b/api/chalicelib/core/errors.py @@ -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("--------------------") diff --git a/ee/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql b/ee/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql index 3586ff63a..68376168d 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql @@ -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; \ No newline at end of file diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 792003dab..02c6e135a 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -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 diff --git a/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql b/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql index 4ce5009a3..c27fa3e7a 100644 --- a/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql +++ b/scripts/helm/db/init_dbs/postgresql/1.8.2/1.8.2.sql @@ -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; \ No newline at end of file diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 9e3a0f924..5cf4ed75e 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -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');