From a37f11e261d5059778a8a7c27db281ff8c1f7747 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 3 Mar 2022 19:23:56 +0100 Subject: [PATCH] feat(api): custom_metrics group elements for pieChart --- api/chalicelib/core/custom_metrics.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/chalicelib/core/custom_metrics.py b/api/chalicelib/core/custom_metrics.py index 7d46cc316..53864c624 100644 --- a/api/chalicelib/core/custom_metrics.py +++ b/api/chalicelib/core/custom_metrics.py @@ -29,6 +29,12 @@ def __try_live(project_id, data: schemas.CreateCustomMetricsSchema): r["seriesName"] = s.name if s.name else i + 1 r["seriesId"] = s.series_id if s.series_id else None results[-1] = r + elif data.view_type == schemas.MetricTableViewType.pie_chart: + if len(results[i].get("values", [])) > 8: + results[i]["values"] = results[i]["values"][:8] \ + + [{"name": "Others", "group": True, + "sessionCount": sum(r["sessionCount"] for r in results[i][8:])}] + return results