* feat(DB): rearranged queries feat(DB): ready for v1.15.0 * refactor(chalice): upgraded dependencies refactor(crons): upgraded dependencies refactor(alerts): upgraded dependencies * fix(chalice): return error when updating inexistant webhook * feat(chalice): fixed delete webhook response * feat(chalice): limit webhooks name length * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies * fix(chalice): remove urllib3 dependency * feat(chalice): remove FOSS to pydantic v2 * fix(chalice): freeze urllib3 to not have conflicts between boto3 and requests * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress feat(chalice): upgraded dependencies * feat(chalice): refactored schema * fix(chalice): pull rebase dev * feat(DB): transfer size support * feat(chalice): support service account * feat(chalice): support service account * fix(chalice): fixed refactored PayloadSchema-name * feat(chalice): path analysis * feat(chalice): support service account 1/2 * feat(DB): timezone support * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies feat(assist): upgraded dependencies feat(sourcemaps): upgraded dependencies * feat(chalice): path analysis schema changes * feat(chalice): path analysis query change * feat(chalice): path analysis query change * feat(chalice): ios replay support * feat(chalice): ios replay support * feat(chalice): path analysis changes * feat(chalice): upgraded dependencies * feat(chalice): simple hide minor paths * feat(chalice): path analysis density * feat(chalice): session's replay ios events * feat(chalice): fixed typo * feat(chalice): support project's platform * feat(DB): support project's platform * feat(chalice): path analysis EE in progress * feat(chalice): project's platform API * feat(chalice): fixed create project * feat(chalice): EE path analysis in progress * feat(chalice): EE path analysis refactor(chalice): support specific database name for clickhouse-client * feat(chalice): upgraded dependencies feat(chalice): path analysis specific event type for startPoint feat(chalice): path analysis specific event type for endPoint feat(chalice): path analysis specific event type for exclude * refactoring(chalice): changed IOS click event type
68 lines
2.8 KiB
Python
68 lines
2.8 KiB
Python
from typing import List
|
|
|
|
import schemas
|
|
from chalicelib.core import significance
|
|
from chalicelib.utils import helper
|
|
from chalicelib.utils import sql_helper as sh
|
|
|
|
|
|
def filter_stages(stages: List[schemas.SessionSearchEventSchema2]):
|
|
ALLOW_TYPES = [schemas.EventType.click, schemas.EventType.input,
|
|
schemas.EventType.location, schemas.EventType.custom,
|
|
schemas.EventType.click_ios, schemas.EventType.input_ios,
|
|
schemas.EventType.view_ios, schemas.EventType.custom_ios, ]
|
|
return [s for s in stages if s.type in ALLOW_TYPES and s.value is not None]
|
|
|
|
|
|
def __parse_events(f_events: List[dict]):
|
|
return [schemas.SessionSearchEventSchema2.parse_obj(e) for e in f_events]
|
|
|
|
|
|
def __fix_stages(f_events: List[schemas.SessionSearchEventSchema2]):
|
|
if f_events is None:
|
|
return
|
|
events = []
|
|
for e in f_events:
|
|
if e.operator is None:
|
|
e.operator = schemas.SearchEventOperator._is
|
|
|
|
if not isinstance(e.value, list):
|
|
e.value = [e.value]
|
|
is_any = sh.isAny_opreator(e.operator)
|
|
if not is_any and isinstance(e.value, list) and len(e.value) == 0:
|
|
continue
|
|
events.append(e)
|
|
return events
|
|
|
|
|
|
# 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.CardSeriesFilterSchema):
|
|
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, 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"]:
|
|
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}
|
|
|
|
|
|
# def get_issues_on_the_fly_widget(project_id, data: schemas.FunnelSearchPayloadSchema):
|
|
def get_issues_on_the_fly_widget(project_id, data: schemas.CardSeriesFilterSchema):
|
|
data.events = filter_stages(data.events)
|
|
data.events = __fix_stages(data.events)
|
|
if len(data.events) < 0:
|
|
return {"issues": []}
|
|
|
|
return {
|
|
"issues": helper.dict_to_camel_case(
|
|
significance.get_issues_list(filter_d=data, project_id=project_id, first_stage=1,
|
|
last_stage=len(data.events)))}
|