From 774f14d40e9b4a92017d15cc7d9841c8cc0b4a87 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 3 Feb 2023 11:13:39 +0100 Subject: [PATCH 1/5] feat(chalice): return query-left-name for alerts --- api/chalicelib/core/alerts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/chalicelib/core/alerts.py b/api/chalicelib/core/alerts.py index 51f42e640..3c8b00c54 100644 --- a/api/chalicelib/core/alerts.py +++ b/api/chalicelib/core/alerts.py @@ -30,9 +30,11 @@ def get_all(project_id): with pg_client.PostgresClient() as cur: query = cur.mogrify("""\ SELECT alerts.*, - COALESCE(metric_series.name, query ->> 'left') AS lef_name + COALESCE(metrics.name || '.' || (COALESCE(metric_series.name, 'series ' || index)) || '.count', + query ->> 'left') AS series_name FROM public.alerts LEFT JOIN metric_series USING (series_id) + LEFT JOIN metrics USING (metric_id) WHERE alerts.project_id =%(project_id)s AND alerts.deleted_at ISNULL ORDER BY alerts.created_at;""", From 34a028590498ba2e5d102728418bd17e9877ffe6 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 2 Feb 2023 18:55:55 +0100 Subject: [PATCH 2/5] change(ui): fix alert reset, logout --- .../components/Dashboard/components/Alerts/NewAlert.tsx | 3 +-- frontend/app/duck/user.js | 2 +- frontend/app/types/alert.ts | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx b/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx index 97319e938..717c7ea59 100644 --- a/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/NewAlert.tsx @@ -94,8 +94,7 @@ const NewAlert = (props: IProps) => { useEffect(() => { if (list.length > 0) { const alertId = location.pathname.split('/').pop(); - const currentAlert = list - .find((alert: Alert) => alert.alertId === String(alertId)); + const currentAlert = list.find((alert: Alert) => alert.alertId === String(alertId)); if (currentAlert) { init(currentAlert) } diff --git a/frontend/app/duck/user.js b/frontend/app/duck/user.js index d938c8c09..f7f4e6a08 100644 --- a/frontend/app/duck/user.js +++ b/frontend/app/duck/user.js @@ -143,7 +143,7 @@ export const fetchUserInfo = () => ({ export function logout() { return { types: DELETE.toArray(), - call: client => client.post('/logout') + call: client => client.get('/logout') }; } diff --git a/frontend/app/types/alert.ts b/frontend/app/types/alert.ts index 052de7c1d..a9600d024 100644 --- a/frontend/app/types/alert.ts +++ b/frontend/app/types/alert.ts @@ -36,7 +36,7 @@ export interface IAlert { condition: string; } -const defaults = { +const getDefaults = () => ({ alertId: '', projectId: undefined, name: 'Untitled Alert', @@ -61,7 +61,7 @@ const defaults = { hasNotification: false, metric: '', condition: '', -} as unknown as IAlert +}) as unknown as IAlert export default class Alert { alertId: IAlert["alertId"] @@ -90,7 +90,8 @@ export default class Alert { condition: IAlert["condition"] isExists = false - constructor(item: Partial = defaults, isExists: boolean) { + constructor(item: Partial = {}, isExists: boolean) { + const defaults = getDefaults() Object.assign(defaults, item) const options = defaults.options || { currentPeriod: 15, previousPeriod: 15, message: [] }; From 20789915066e91bde82f8f8408d365892d2bad95 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 3 Feb 2023 11:12:34 +0100 Subject: [PATCH 3/5] change(ui) - alerts use seriesName --- .../components/Dashboard/components/Alerts/AlertListItem.tsx | 2 +- frontend/app/types/alert.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx index 4a2a97283..e3412bdce 100644 --- a/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx +++ b/frontend/app/components/Dashboard/components/Alerts/AlertListItem.tsx @@ -127,7 +127,7 @@ function AlertListItem(props: Props) { {'When the '} {alert.detectionMethod} {' of '} - {alert.query.left} + {alert.seriesName} {' is '} {alert.query.operator} diff --git a/frontend/app/types/alert.ts b/frontend/app/types/alert.ts index a9600d024..124e393e2 100644 --- a/frontend/app/types/alert.ts +++ b/frontend/app/types/alert.ts @@ -20,6 +20,7 @@ export interface IAlert { detectionMethod: string; detection_method?: string; change: string; + seriesName: string; query: { left: string, operator: string, right: string }; options: { currentPeriod: number, previousPeriod: number, message: {type: string, value: string}[] }; createdAt?: number; @@ -74,6 +75,7 @@ export default class Alert { detectionMethod: IAlert["detectionMethod"] detection_method: IAlert["detection_method"] change: IAlert["change"] + seriesName: IAlert["seriesName"] query: IAlert["query"] options: IAlert["options"] createdAt?: IAlert["createdAt"] From 5fb281567698a1306b2063323e25d6e4fb48d507 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 3 Feb 2023 11:12:55 +0100 Subject: [PATCH 4/5] fix(ui) - user entity createdAt --- frontend/app/mstore/types/user.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/mstore/types/user.ts b/frontend/app/mstore/types/user.ts index 9b5a06b43..e867be263 100644 --- a/frontend/app/mstore/types/user.ts +++ b/frontend/app/mstore/types/user.ts @@ -41,7 +41,7 @@ export default class User { this.userId = json.userId || json.id; // TODO api returning id this.name = json.name; this.email = json.email; - this.createdAt = json.createdAt && DateTime.fromMillis(json.createdAt || 0) + this.createdAt = json.createdAt && DateTime.fromMillis(new Date(json.createdAt).getTime()) this.isAdmin = json.admin this.isSuperAdmin = json.superAdmin this.isJoined = json.joined From bc7ad49c63b63f2ed889ec1ff523590fe25f0df9 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 3 Feb 2023 11:13:09 +0100 Subject: [PATCH 5/5] change(ui) - cards api call --- frontend/app/services/MetricService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/services/MetricService.ts b/frontend/app/services/MetricService.ts index 1b46c76f3..94f4b8288 100644 --- a/frontend/app/services/MetricService.ts +++ b/frontend/app/services/MetricService.ts @@ -98,7 +98,7 @@ export default class MetricService { } fetchIssue(metricId: string, issueId: string, params: any): Promise { - return this.client.post(`/custom_metrics/${metricId}/issues/${issueId}/sessions`, params) + return this.client.post(`/cards/${metricId}/issues/${issueId}/sessions`, params) .then((response: { json: () => any; }) => response.json()) .then((response: { data: any; }) => response.data || {}); }