feat(api): funnel widget
This commit is contained in:
parent
b5a646b233
commit
8d49a588e4
3 changed files with 23 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ import json
|
|||
from typing import Union
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import sessions
|
||||
from chalicelib.core import sessions, funnels
|
||||
from chalicelib.utils import helper, pg_client
|
||||
from chalicelib.utils.TimeUTC import TimeUTC
|
||||
|
||||
|
|
@ -43,6 +43,11 @@ def __try_live(project_id, data: schemas.TryCustomMetricsPayloadSchema):
|
|||
|
||||
|
||||
def merged_live(project_id, data: schemas.TryCustomMetricsPayloadSchema):
|
||||
if data.metric_type == schemas.MetricType.funnel:
|
||||
if len(data.series) == 0:
|
||||
return {}
|
||||
return funnels.get_top_insights_on_the_fly_widget(project_id=project_id, data=data.series[0].filter)
|
||||
|
||||
series_charts = __try_live(project_id=project_id, data=data)
|
||||
if data.view_type == schemas.MetricTimeseriesViewType.progress or data.metric_type == schemas.MetricType.table:
|
||||
return series_charts
|
||||
|
|
|
|||
|
|
@ -251,6 +251,22 @@ def get_top_insights_on_the_fly(funnel_id, user_id, project_id, data: schemas.Fu
|
|||
"totalDropDueToIssues": total_drop_due_to_issues}}
|
||||
|
||||
|
||||
# def get_top_insights_on_the_fly_widget(project_id, data: schemas.FunnelInsightsPayloadSchema):
|
||||
def get_top_insights_on_the_fly_widget(project_id, data: schemas.CustomMetricSeriesFilterSchema):
|
||||
data.events = filter_stages(__parse_events(data.events))
|
||||
data.events = __fix_stages(data.events)
|
||||
if len(data.events) == 0:
|
||||
return {"stages": [], "totalDropDueToIssues": 0}
|
||||
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:
|
||||
if total_drop_due_to_issues > insights[0]["sessionsCount"]:
|
||||
total_drop_due_to_issues = insights[0]["sessionsCount"]
|
||||
insights[-1]["dropDueToIssues"] = total_drop_due_to_issues
|
||||
return {"stages": insights,
|
||||
"totalDropDueToIssues": total_drop_due_to_issues}
|
||||
|
||||
|
||||
def get_issues(project_id, user_id, funnel_id, range_value=None, start_date=None, end_date=None):
|
||||
f = get(funnel_id=funnel_id, project_id=project_id, user_id=user_id, flatten=False)
|
||||
if f is None:
|
||||
|
|
|
|||
|
|
@ -795,6 +795,7 @@ class MetricType(str, Enum):
|
|||
timeseries = "timeseries"
|
||||
table = "table"
|
||||
predefined = "predefined"
|
||||
funnel = "funnel"
|
||||
|
||||
|
||||
class TableMetricOfType(str, Enum):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue