feat(api): table of sessions widget
This commit is contained in:
parent
53fc845f9a
commit
23a98d83d7
2 changed files with 25 additions and 2 deletions
|
|
@ -48,7 +48,10 @@ def __is_funnel_chart(data: schemas.TryCustomMetricsPayloadSchema):
|
|||
|
||||
def __get_funnel_chart(project_id, data: schemas.TryCustomMetricsPayloadSchema):
|
||||
if len(data.series) == 0:
|
||||
return {}
|
||||
return {
|
||||
"stages": [],
|
||||
"totalDropDueToIssues": 0
|
||||
}
|
||||
return funnels.get_top_insights_on_the_fly_widget(project_id=project_id, data=data.series[0].filter)
|
||||
|
||||
|
||||
|
|
@ -61,15 +64,34 @@ def __is_errors_list(data):
|
|||
|
||||
def __get_errors_list(project_id, user_id, data):
|
||||
if len(data.series) == 0:
|
||||
return []
|
||||
return {
|
||||
"total": 0,
|
||||
"errors": []
|
||||
}
|
||||
return errors.search(data.series[0].filter, project_id=project_id, user_id=user_id)
|
||||
|
||||
|
||||
def __is_sessions_list(data):
|
||||
return data.metric_type == schemas.MetricType.table \
|
||||
and data.metric_of == schemas.TableMetricOfType.sessions
|
||||
|
||||
|
||||
def __get_sessions_list(project_id, user_id, data):
|
||||
if len(data.series) == 0:
|
||||
return {
|
||||
"total": 0,
|
||||
"sessions": []
|
||||
}
|
||||
return sessions.search2_pg(data=data.series[0].filter, project_id=project_id, user_id=user_id)
|
||||
|
||||
|
||||
def merged_live(project_id, data: schemas.TryCustomMetricsPayloadSchema, user_id=None):
|
||||
if __is_funnel_chart(data):
|
||||
return __get_funnel_chart(project_id=project_id, data=data)
|
||||
elif __is_errors_list(data):
|
||||
return __get_errors_list(project_id=project_id, user_id=user_id, data=data)
|
||||
elif __is_sessions_list(data):
|
||||
return __get_sessions_list(project_id=project_id, user_id=user_id, data=data)
|
||||
|
||||
series_charts = __try_live(project_id=project_id, data=data)
|
||||
if data.view_type == schemas.MetricTimeseriesViewType.progress or data.metric_type == schemas.MetricType.table:
|
||||
|
|
|
|||
|
|
@ -810,6 +810,7 @@ class TableMetricOfType(str, Enum):
|
|||
user_id = FilterType.user_id.value
|
||||
issues = FilterType.issue.value
|
||||
visited_url = EventType.location.value
|
||||
sessions = "SESSIONS"
|
||||
|
||||
|
||||
class TimeseriesMetricOfType(str, Enum):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue