From cd80aa85ea0e3bee2bc41d49f1883cd6ddbfd151 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Thu, 13 Mar 2025 13:45:27 +0100 Subject: [PATCH] refactor(chalice): refactored error-details code --- api/chalicelib/core/errors/errors_ch.py | 4 ++-- api/chalicelib/core/errors/errors_pg.py | 4 ++-- api/chalicelib/core/errors/modules/helper.py | 9 ++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/chalicelib/core/errors/errors_ch.py b/api/chalicelib/core/errors/errors_ch.py index 5e984f0ed..1c67e871d 100644 --- a/api/chalicelib/core/errors/errors_ch.py +++ b/api/chalicelib/core/errors/errors_ch.py @@ -1,11 +1,11 @@ import schemas from chalicelib.core import metadata +from chalicelib.core.errors import errors_legacy +from chalicelib.core.errors.modules import errors_helper from chalicelib.core.errors.modules import sessions from chalicelib.utils import ch_client, exp_ch_helper from chalicelib.utils import helper, metrics_helper from chalicelib.utils.TimeUTC import TimeUTC -from . import errors as errors_legacy -from chalicelib.core.errors.modules import errors_helper def _multiple_values(values, value_key="value"): diff --git a/api/chalicelib/core/errors/errors_pg.py b/api/chalicelib/core/errors/errors_pg.py index 6799e9968..5827a2440 100644 --- a/api/chalicelib/core/errors/errors_pg.py +++ b/api/chalicelib/core/errors/errors_pg.py @@ -1,13 +1,13 @@ import json -from typing import Optional, List +from typing import List import schemas +from chalicelib.core.errors.modules import errors_helper from chalicelib.core.sessions import sessions_search from chalicelib.core.sourcemaps import sourcemaps from chalicelib.utils import pg_client, helper from chalicelib.utils.TimeUTC import TimeUTC from chalicelib.utils.metrics_helper import get_step_size -from chalicelib.core.errors.modules import errors_helper def get(error_id, family=False) -> dict | List[dict]: diff --git a/api/chalicelib/core/errors/modules/helper.py b/api/chalicelib/core/errors/modules/helper.py index 4515c6126..af0c9e40b 100644 --- a/api/chalicelib/core/errors/modules/helper.py +++ b/api/chalicelib/core/errors/modules/helper.py @@ -1,3 +1,8 @@ +from typing import Optional + +import schemas + + def __get_basic_constraints(platform: Optional[schemas.PlatformType] = None, time_constraint: bool = True, startTime_arg_name: str = "startDate", endTime_arg_name: str = "endDate", chart: bool = False, step_size_name: str = "step_size", @@ -18,8 +23,10 @@ def __get_basic_constraints(platform: Optional[schemas.PlatformType] = None, tim ch_sub_query.append("user_device_type = 'desktop'") return ch_sub_query + def __get_basic_constraints_ch(platform=None, time_constraint=True, startTime_arg_name="startDate", - endTime_arg_name="endDate", type_condition=True, project_key="project_id", table_name=None): + endTime_arg_name="endDate", type_condition=True, project_key="project_id", + table_name=None): ch_sub_query = [f"{project_key} =toUInt16(%(project_id)s)"] if table_name is not None: table_name = table_name + "."