示例#1
0
def test_query_extension_processing(
    raw_data: dict,
    expected_conditions: Sequence[Condition],
    expected_granularity: int,
):
    state.set_config('max_days', 1)
    extension = TimeSeriesExtension(
        default_granularity=60,
        default_window=datetime.timedelta(days=5),
        timestamp_column='timestamp',
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query(
        {"conditions": []},
        TableSource("my_table", ColumnSet([])),
    )

    request_settings = RequestSettings(turbo=False,
                                       consistent=False,
                                       debug=False)

    extension.get_processor().process_query(query, valid_data,
                                            request_settings)
    assert query.get_conditions() == expected_conditions
    assert query.get_granularity() == expected_granularity
示例#2
0
def test_query_extension_processing(raw_data: dict,
                                    expected_conditions: Sequence[Condition]):
    state.set_config('max_days', 1)
    extension = TimeSeriesExtension(
        default_granularity=3600,
        default_window=datetime.timedelta(days=5),
        timestamp_column='timestamp',
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query({"conditions": []})

    extension.get_processor().process_query(query, valid_data)
    assert query.get_conditions() == expected_conditions
示例#3
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=7),
             timestamp_column="timestamp",
         ),
         "organization": OrganizationExtension(),
     }
示例#4
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'performance': PerformanceExtension(),
         'project': ProjectExtension(),
         'timeseries': TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='timestamp',
         ),
     }
示例#5
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "project": ProjectExtension(
             processor=ProjectExtensionProcessor(project_column="project_id")
         ),
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column="start_ts",
         ),
     }
示例#6
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'project':
         ProjectExtension(processor=ProjectExtensionProcessor()),
         'timeseries':
         TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='start_ts',
         ),
     }
def test_query_extension_processing(
    raw_data: dict,
    expected_conditions: Sequence[Condition],
    expected_ast_condition: Expression,
    expected_granularity: int,
):
    state.set_config("max_days", 1)
    extension = TimeSeriesExtension(
        default_granularity=60,
        default_window=timedelta(days=5),
        timestamp_column="timestamp",
    )
    valid_data = validate_jsonschema(raw_data, extension.get_schema())
    query = Query({"conditions": []}, TableSource("my_table", ColumnSet([])),)

    request_settings = HTTPRequestSettings()

    extension.get_processor().process_query(query, valid_data, request_settings)
    assert query.get_conditions() == expected_conditions
    assert query.get_condition_from_ast() == expected_ast_condition
    assert query.get_granularity() == expected_granularity
示例#8
0
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         'project':
         ProjectExtension(processor=ProjectWithGroupsProcessor(
             project_column="events.project_id")),
         'timeseries':
         TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column='events.timestamp',
         ),
     }
示例#9
0
文件: groups.py 项目: ruezetle/snuba
 def get_extensions(self) -> Mapping[str, QueryExtension]:
     return {
         "project": ProjectExtension(
             processor=ProjectWithGroupsProcessor(
                 project_column="events.project_id", replacer_state_name=None,
             )
         ),
         "timeseries": TimeSeriesExtension(
             default_granularity=3600,
             default_window=timedelta(days=5),
             timestamp_column="events.timestamp",
         ),
     }