feat(chalice): cards remove useless series
feat(chalice): cards handle missing insight-categories
This commit is contained in:
parent
9005e8f299
commit
4d599096d2
2 changed files with 24 additions and 0 deletions
|
|
@ -1016,6 +1016,9 @@ class CreateCardSchema(CardChartSchema):
|
|||
if values.get("metricType") == MetricType.funnel.value and \
|
||||
values.get("series") is not None and len(values["series"]) > 1:
|
||||
values["series"] = [values["series"][0]]
|
||||
elif values.get("metricType") not in (MetricType.table.value, MetricType.timeseries.value) and \
|
||||
values.get("series") is not None and len(values["series"]) > 0:
|
||||
values["series"] = []
|
||||
|
||||
return values
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,16 @@ class GetInsightsSchema(BaseModel):
|
|||
# time_step: int = Field(default=3600)
|
||||
categories: List[InsightCategories] = Field(..., min_items=1)
|
||||
|
||||
# This is used to handle wrong values sent by the UI
|
||||
@root_validator(pre=True)
|
||||
def transform(cls, values):
|
||||
if values.get("categories") is None or len(values.get("categories")) == 0:
|
||||
values["categories"] = []
|
||||
for v in InsightCategories:
|
||||
values["categories"].append(v.value)
|
||||
|
||||
return values
|
||||
|
||||
class Config:
|
||||
alias_generator = schemas.attribute_to_camel_case
|
||||
|
||||
|
|
@ -153,6 +163,17 @@ class CreateCardSchema(schemas.CreateCardSchema):
|
|||
def restrictions(cls, values):
|
||||
return values
|
||||
|
||||
# This is used to handle wrong values sent by the UI
|
||||
@root_validator(pre=True)
|
||||
def transform_ee(cls, values):
|
||||
if values.get("metricType") == schemas.MetricType.insights and (
|
||||
values.get("metricValue") is None or len(values.get("metricValue")) == 0):
|
||||
values["metricValue"] = []
|
||||
for v in InsightCategories:
|
||||
values["metricValue"].append(v.value)
|
||||
|
||||
return values
|
||||
|
||||
@root_validator
|
||||
def validator(cls, values):
|
||||
values = super().validator(values)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue