From 06cada34047bc4900b7cbebd43c4743ca3472eee Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 2 Feb 2023 18:40:02 +0100 Subject: [PATCH 1/2] feat(chalice): return query-left-name for alerts --- api/chalicelib/core/alerts.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/api/chalicelib/core/alerts.py b/api/chalicelib/core/alerts.py index 7da05c2ee..51f42e640 100644 --- a/api/chalicelib/core/alerts.py +++ b/api/chalicelib/core/alerts.py @@ -29,10 +29,13 @@ def get(id): def get_all(project_id): with pg_client.PostgresClient() as cur: query = cur.mogrify("""\ - SELECT * - FROM public.alerts - WHERE project_id =%(project_id)s AND deleted_at ISNULL - ORDER BY created_at;""", + SELECT alerts.*, + COALESCE(metric_series.name, query ->> 'left') AS lef_name + FROM public.alerts + LEFT JOIN metric_series USING (series_id) + WHERE alerts.project_id =%(project_id)s + AND alerts.deleted_at ISNULL + ORDER BY alerts.created_at;""", {"project_id": project_id}) cur.execute(query=query) all = helper.list_to_camel_case(cur.fetchall()) From cba593604468d8f650cd21ac1a006589fab9b8e5 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 2 Feb 2023 18:15:05 +0100 Subject: [PATCH 2/2] change(ui): fix alert reset --- .../app/components/Dashboard/components/Alerts/NewAlert.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx b/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx index 258b550cd..97319e938 100644 --- a/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx @@ -96,7 +96,9 @@ const NewAlert = (props: IProps) => { const alertId = location.pathname.split('/').pop(); const currentAlert = list .find((alert: Alert) => alert.alertId === String(alertId)); - init(currentAlert || {}); + if (currentAlert) { + init(currentAlert) + } } }, [list]);