From bebe6169f0a05ce32960dd1fb6d63984f15385ee Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 3 Mar 2022 13:28:19 +0100 Subject: [PATCH] feat(api): custom_metrics changed countProgress formula --- api/chalicelib/core/custom_metrics.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/chalicelib/core/custom_metrics.py b/api/chalicelib/core/custom_metrics.py index ecb61732f..d4e0b6b45 100644 --- a/api/chalicelib/core/custom_metrics.py +++ b/api/chalicelib/core/custom_metrics.py @@ -22,7 +22,9 @@ def __try_live(project_id, data: schemas.CreateCustomMetricsSchema): r["previousCount"] = sessions.search2_series(data=s.filter, project_id=project_id, density=data.density, view_type=data.view_type, metric_type=data.metric_type, metric_of=data.metric_of, metric_value=data.metric_value) - r["countProgress"] = helper.__progress(old_val=r["previousCount"], new_val=r["count"]) + # r["countProgress"] = helper.__progress(old_val=r["previousCount"], new_val=r["count"]) + r["countProgress"] = ((r["count"] - r["previousCount"]) / r["previousCount"]) * 100 \ + if r["previousCount"] > 0 else 0 r["seriesName"] = s.name if s.name else i + 1 r["seriesId"] = s.series_id if s.series_id else None results[-1] = r