fix(query-object): extra time-range-endpoints (#13331)

Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
John Bodley 2021-03-03 13:22:07 +13:00 committed by GitHub
parent f2616294e6
commit 694ae6f90e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -30,6 +30,7 @@ from superset.utils.core import (
FilterOperator,
PostProcessingBoxplotWhiskerType,
PostProcessingContributionOrientation,
TimeRangeEndpoint,
)
#
@ -769,13 +770,7 @@ class ChartDataFilterSchema(Schema):
class ChartDataExtrasSchema(Schema):
time_range_endpoints = fields.List(
fields.String(
validate=validate.OneOf(choices=("unknown", "inclusive", "exclusive")),
description="A list with two values, stating if start/end should be "
"inclusive/exclusive.",
)
)
time_range_endpoints = fields.List(EnumField(TimeRangeEndpoint, by_value=True))
relative_start = fields.String(
description="Start time for relative time deltas. "
'Default: `config["DEFAULT_RELATIVE_START_TIME"]`',

View File

@ -181,8 +181,10 @@ class QueryObject:
self.order_desc = order_desc
self.extras = extras
if config["SIP_15_ENABLED"] and "time_range_endpoints" not in self.extras:
self.extras["time_range_endpoints"] = get_time_range_endpoints(form_data={})
if config["SIP_15_ENABLED"]:
self.extras["time_range_endpoints"] = get_time_range_endpoints(
form_data=self.extras
)
self.columns = columns
self.groupby = groupby or []

View File

@ -17,13 +17,16 @@
import copy
from typing import Any, Dict, List
from superset.utils.core import AnnotationType, DTTM_ALIAS
from superset.utils.core import AnnotationType, DTTM_ALIAS, TimeRangeEndpoint
from tests.base_tests import get_table_by_name
query_birth_names = {
"extras": {
"where": "",
"time_range_endpoints": ["inclusive", "exclusive"],
"time_range_endpoints": (
TimeRangeEndpoint.INCLUSIVE,
TimeRangeEndpoint.EXCLUSIVE,
),
"time_grain_sqla": "P1D",
},
"groupby": ["name"],