From c7c55195a21b48778f8de1217e8de315d304be49 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Wed, 3 Aug 2022 15:17:50 +0200 Subject: [PATCH] feat(chalice): refactored search sessions --- ee/api/chalicelib/core/errors.py | 8 ++++---- ee/api/chalicelib/core/sessions_ee.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/api/chalicelib/core/errors.py b/ee/api/chalicelib/core/errors.py index f7cb40436..b79c43fe3 100644 --- a/ee/api/chalicelib/core/errors.py +++ b/ee/api/chalicelib/core/errors.py @@ -462,7 +462,7 @@ def __get_basic_constraints_pg(platform=None, time_constraint=True, startTime_ar return ch_sub_query -def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): +def search_pg(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): empty_response = {'total': 0, 'errors': [] } @@ -488,7 +488,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): if len(data.events) > 0 or len(data.filters) > 0: print("-- searching for sessions before errors") # if favorite_only=True search for sessions associated with favorite_error - statuses = sessions.search2_pg(data=data, project_id=project_id, user_id=user_id, errors_only=True, + statuses = sessions.search_sessions(data=data, project_id=project_id, user_id=user_id, errors_only=True, error_status=data.status) if len(statuses) == 0: return empty_response @@ -634,7 +634,7 @@ def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): # refactor this function after clickhouse structure changes (missing search by query) -def search_deprecated(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): +def search(data: schemas.SearchErrorsSchema, project_id, user_id, flows=False): empty_response = {"data": { 'total': 0, 'errors': [] @@ -657,7 +657,7 @@ def search_deprecated(data: schemas.SearchErrorsSchema, project_id, user_id, flo if len(data.events) > 0 or len(data.filters) > 0 or data.status != schemas.ErrorStatus.all: print("-- searching for sessions before errors") # if favorite_only=True search for sessions associated with favorite_error - statuses = sessions.search2_pg(data=data, project_id=project_id, user_id=user_id, errors_only=True, + statuses = sessions.search_sessions(data=data, project_id=project_id, user_id=user_id, errors_only=True, error_status=data.status) if len(statuses) == 0: return empty_response diff --git a/ee/api/chalicelib/core/sessions_ee.py b/ee/api/chalicelib/core/sessions_ee.py index a16317d82..0a4295b15 100644 --- a/ee/api/chalicelib/core/sessions_ee.py +++ b/ee/api/chalicelib/core/sessions_ee.py @@ -225,7 +225,7 @@ def _isUndefined_operator(op: schemas.SearchEventOperator): return op in [schemas.SearchEventOperator._is_undefined] -def search2_pg(data: schemas.SessionsSearchPayloadSchema, project_id, user_id, errors_only=False, +def search_sessions(data: schemas.SessionsSearchPayloadSchema, project_id, user_id, errors_only=False, error_status=schemas.ErrorStatus.all, count_only=False, issue=None): full_args, query_part = search_query_parts(data=data, error_status=error_status, errors_only=errors_only, favorite_only=data.bookmarked, issue=issue, project_id=project_id,