feat(api): custom_metrics support metric_format

feat(api): custom_metrics metric_value accept wrong values
This commit is contained in:
Taha Yassine Kraiem 2022-03-02 20:13:18 +01:00
parent 8c151e5bea
commit fb72c2894b

View file

@ -778,6 +778,15 @@ class CreateCustomMetricsSchema(CustomMetricChartPayloadSchema):
metric_format: Optional[str] = Field(None)
# metricFraction: float = Field(None, gt=0, lt=1)
# This is used to handle wrong values sent by the UI
@root_validator(pre=True)
def remove_metric_value(cls, values):
if values.get("metric_type") == MetricType.timeseries \
or values.get("metric_type") == MetricType.table \
and values.get("metric_of") != TableMetricOfType.issues:
values["metric_of"] = []
return values
@root_validator
def validator(cls, values):
if values.get("metric_type") == MetricType.table: