diff --git a/api/chalicelib/core/significance.py b/api/chalicelib/core/significance.py index e020fcfd5..2b30febb0 100644 --- a/api/chalicelib/core/significance.py +++ b/api/chalicelib/core/significance.py @@ -457,9 +457,9 @@ def get_stages(stages, rows): drop = int(100 * (session_counts[i] - session_counts[i + 1]) / session_counts[i]) stages_list.append( - {"value": stage["value"], - "type": stage["type"], - "operator": stage["operator"], + {"value": stage.value, + "type": stage.type, + "operator": stage.operator, "sessionsCount": session_counts[i + 1], "drop_pct": drop, "usersCount": users_counts[i + 1], @@ -587,8 +587,8 @@ def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id): stages_list = get_stages(stages, rows) # Obtain the second part of the output total_drop_due_to_issues = get_issues(stages, rows, - first_stage=filter_d.get("firstStage"), - last_stage=filter_d.get("lastStage"), + first_stage=1, + last_stage=len(filter_d.events), drop_only=True) return stages_list, total_drop_due_to_issues @@ -609,45 +609,3 @@ def get_issues_list(filter_d: schemas.CardSeriesFilterSchema, project_id, first_ # output['critical_issues_count'] = n_critical_issues output = {**output, **issues_dict} return output - - -def get_overview(filter_d, project_id, first_stage=None, last_stage=None): - output = dict() - stages = filter_d["events"] - # TODO: handle 1 stage alone - if len(stages) == 0: - return {"stages": [], - "criticalIssuesCount": 0} - elif len(stages) == 1: - # TODO: count sessions, and users for single stage - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - return output - # The result of the multi-stage query - rows = get_stages_and_events(filter_d=filter_d, project_id=project_id) - if len(rows) == 0: - # PS: not sure what to return if rows are empty - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - output['criticalIssuesCount'] = 0 - return output - # Obtain the first part of the output - stages_list = get_stages(stages, rows) - - # Obtain the second part of the output - n_critical_issues, issues_dict, total_drop_due_to_issues = get_issues(stages, rows, first_stage=first_stage, - last_stage=last_stage) - - output['stages'] = stages_list - output['criticalIssuesCount'] = n_critical_issues - return output diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index edd1b9f98..9f9c71842 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -761,6 +761,9 @@ class SessionsSearchPayloadSchema(_TimedSchema, _PaginatedSchema): def merge_identical_filters(cls, values): i = 0 while i < len(values): + if values[i].is_event: + i += 1 + continue j = i + 1 while j < len(values): if values[i].type == values[j].type: @@ -1024,16 +1027,6 @@ class CardSessionsSchema(_TimedSchema, _PaginatedSchema): v["isEvent"] = ProductAnalyticsSelectedEventType.has_value(v["type"]) return values - @model_validator(mode="before") - def remove_wrong_filter_values(cls, values): - for f in values.get("filters", []): - vals = [] - for v in f.get("value", []): - if v is not None: - vals.append(v) - f["value"] = vals - return values - @model_validator(mode="before") def __enforce_default(cls, values): if values.get("startTimestamp") is None: diff --git a/ee/api/chalicelib/core/significance.py b/ee/api/chalicelib/core/significance.py index 003fea244..f6a77e72d 100644 --- a/ee/api/chalicelib/core/significance.py +++ b/ee/api/chalicelib/core/significance.py @@ -463,9 +463,9 @@ def get_stages(stages, rows): drop = int(100 * (session_counts[i] - session_counts[i + 1]) / session_counts[i]) stages_list.append( - {"value": stage["value"], - "type": stage["type"], - "operator": stage["operator"], + {"value": stage.value, + "type": stage.type, + "operator": stage.operator, "sessionsCount": session_counts[i + 1], "drop_pct": drop, "usersCount": users_counts[i + 1], @@ -593,8 +593,8 @@ def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id): stages_list = get_stages(stages, rows) # Obtain the second part of the output total_drop_due_to_issues = get_issues(stages, rows, - first_stage=filter_d.get("firstStage"), - last_stage=filter_d.get("lastStage"), + first_stage=1, + last_stage=len(filter_d.events), drop_only=True) return stages_list, total_drop_due_to_issues @@ -615,45 +615,3 @@ def get_issues_list(filter_d: schemas.CardSeriesFilterSchema, project_id, first_ # output['critical_issues_count'] = n_critical_issues output = {**output, **issues_dict} return output - - -def get_overview(filter_d, project_id, first_stage=None, last_stage=None): - output = dict() - stages = filter_d["events"] - # TODO: handle 1 stage alone - if len(stages) == 0: - return {"stages": [], - "criticalIssuesCount": 0} - elif len(stages) == 1: - # TODO: count sessions, and users for single stage - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - return output - # The result of the multi-stage query - rows = get_stages_and_events(filter_d=filter_d, project_id=project_id) - if len(rows) == 0: - # PS: not sure what to return if rows are empty - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - output['criticalIssuesCount'] = 0 - return output - # Obtain the first part of the output - stages_list = get_stages(stages, rows) - - # Obtain the second part of the output - n_critical_issues, issues_dict, total_drop_due_to_issues = get_issues(stages, rows, first_stage=first_stage, - last_stage=last_stage) - - output['stages'] = stages_list - output['criticalIssuesCount'] = n_critical_issues - return output diff --git a/ee/api/chalicelib/core/significance_exp.py b/ee/api/chalicelib/core/significance_exp.py index df8805961..1235e4108 100644 --- a/ee/api/chalicelib/core/significance_exp.py +++ b/ee/api/chalicelib/core/significance_exp.py @@ -462,9 +462,9 @@ def get_stages(stages, rows): drop = int(100 * (session_counts[i] - session_counts[i + 1]) / session_counts[i]) stages_list.append( - {"value": stage["value"], - "type": stage["type"], - "operator": stage["operator"], + {"value": stage.value, + "type": stage.type, + "operator": stage.operator, "sessionsCount": session_counts[i + 1], "drop_pct": drop, "usersCount": users_counts[i + 1], @@ -592,8 +592,8 @@ def get_top_insights(filter_d: schemas.CardSeriesFilterSchema, project_id): stages_list = get_stages(stages, rows) # Obtain the second part of the output total_drop_due_to_issues = get_issues(stages, rows, - first_stage=filter_d.get("firstStage"), - last_stage=filter_d.get("lastStage"), + first_stage=1, + last_stage=len(filter_d.events), drop_only=True) return stages_list, total_drop_due_to_issues @@ -614,45 +614,3 @@ def get_issues_list(filter_d: schemas.CardSeriesFilterSchema, project_id, first_ # output['critical_issues_count'] = n_critical_issues output = {**output, **issues_dict} return output - - -def get_overview(filter_d, project_id, first_stage=None, last_stage=None): - output = dict() - stages = filter_d["events"] - # TODO: handle 1 stage alone - if len(stages) == 0: - return {"stages": [], - "criticalIssuesCount": 0} - elif len(stages) == 1: - # TODO: count sessions, and users for single stage - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - return output - # The result of the multi-stage query - rows = get_stages_and_events(filter_d=filter_d, project_id=project_id) - if len(rows) == 0: - # PS: not sure what to return if rows are empty - output["stages"] = [{ - "type": stages[0]["type"], - "value": stages[0]["value"], - "sessionsCount": None, - "dropPercentage": None, - "usersCount": None - }] - output['criticalIssuesCount'] = 0 - return output - # Obtain the first part of the output - stages_list = get_stages(stages, rows) - - # Obtain the second part of the output - n_critical_issues, issues_dict, total_drop_due_to_issues = get_issues(stages, rows, first_stage=first_stage, - last_stage=last_stage) - - output['stages'] = stages_list - output['criticalIssuesCount'] = n_critical_issues - return output