From 3cae5e557557b3a4f8c1488a5246feee612181d6 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 14 Apr 2022 16:40:06 +0200 Subject: [PATCH] feat(api): dashboard fixed date-time format for dashboards feat(api): dashboard fixed date-time format for widgets feat(api): dashboard fixed date-time format for series feat(api): dashboard support empty series widgets --- api/chalicelib/core/dashboards2.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/chalicelib/core/dashboards2.py b/api/chalicelib/core/dashboards2.py index a66324532..38fd2bcdf 100644 --- a/api/chalicelib/core/dashboards2.py +++ b/api/chalicelib/core/dashboards2.py @@ -85,7 +85,7 @@ def get_dashboard(project_id, user_id, dashboard_id): FROM (SELECT dashboard_widgets.*, metrics.*, metric_series.series FROM metrics INNER JOIN dashboard_widgets USING (metric_id) - LEFT JOIN LATERAL (SELECT JSONB_AGG(metric_series.* ORDER BY index) AS series + LEFT JOIN LATERAL (SELECT COALESCE(JSONB_AGG(metric_series.* ORDER BY index),'[]') AS series FROM metric_series WHERE metric_series.metric_id = metrics.metric_id AND metric_series.deleted_at ISNULL @@ -102,9 +102,12 @@ def get_dashboard(project_id, user_id, dashboard_id): cur.execute(cur.mogrify(pg_query, params)) row = cur.fetchone() if row is not None: + row["created_at"] = TimeUTC.datetime_to_timestamp(row["created_at"]) for w in row["widgets"]: - row["created_at"] = TimeUTC.datetime_to_timestamp(w["created_at"]) - row["edited_at"] = TimeUTC.datetime_to_timestamp(w["edited_at"]) + w["created_at"] = TimeUTC.datetime_to_timestamp(w["created_at"]) + w["edited_at"] = TimeUTC.datetime_to_timestamp(w["edited_at"]) + for s in w["series"]: + s["created_at"] = TimeUTC.datetime_to_timestamp(s["created_at"]) return helper.dict_to_camel_case(row)