From 7444c2d9991931746995f5ef8a946e2397168c19 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Mon, 20 Jun 2022 18:45:03 +0200 Subject: [PATCH] feat(api): changed funnel's dropDueToIssues --- api/chalicelib/core/funnels.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/chalicelib/core/funnels.py b/api/chalicelib/core/funnels.py index 22774fb16..3239f4705 100644 --- a/api/chalicelib/core/funnels.py +++ b/api/chalicelib/core/funnels.py @@ -260,8 +260,12 @@ def get_top_insights_on_the_fly_widget(project_id, data: schemas.CustomMetricSer insights, total_drop_due_to_issues = significance.get_top_insights(filter_d=data.dict(), project_id=project_id) insights = helper.list_to_camel_case(insights) if len(insights) > 0: + # TODO: check if this correct if total_drop_due_to_issues > insights[0]["sessionsCount"]: - total_drop_due_to_issues = insights[0]["sessionsCount"] + if len(insights) == 0: + total_drop_due_to_issues = 0 + else: + total_drop_due_to_issues = insights[0]["sessionsCount"] - insights[-1]["sessionsCount"] insights[-1]["dropDueToIssues"] = total_drop_due_to_issues return {"stages": insights, "totalDropDueToIssues": total_drop_due_to_issues}