chore(): minor fixes around codebase
This commit is contained in:
@@ -53,6 +53,22 @@ def _validate_calculation_rule(
|
||||
)
|
||||
}
|
||||
)
|
||||
rule_type = rule.get("type")
|
||||
if rule_type and rule_type != metric_type:
|
||||
raise ValidationError(
|
||||
{
|
||||
"calculation_rule": (
|
||||
f"Rule type '{rule_type}' does not match "
|
||||
f"metric_type '{metric_type}'."
|
||||
)
|
||||
}
|
||||
)
|
||||
if metric_type == MetricType.PERCENTILE:
|
||||
percentile = rule.get("percentile")
|
||||
if percentile is not None and not (0 <= percentile <= 100):
|
||||
raise ValidationError(
|
||||
{"calculation_rule": ("Percentile must be between 0 and 100.")}
|
||||
)
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.experiments.services import (
|
||||
experiment_approve,
|
||||
experiment_start,
|
||||
experiment_submit_for_review,
|
||||
)
|
||||
from apps.experiments.tests.helpers import add_two_variants, make_experiment
|
||||
from apps.guardrails.models import GuardrailAction
|
||||
from apps.guardrails.services import guardrail_create
|
||||
from apps.experiments.tests.helpers import make_experiment
|
||||
from apps.metrics.models import ExperimentMetric, MetricDirection, MetricType
|
||||
from apps.metrics.services import (
|
||||
experiment_metric_add,
|
||||
@@ -19,8 +11,6 @@ from apps.metrics.services import (
|
||||
metric_definition_create,
|
||||
metric_definition_update,
|
||||
)
|
||||
from apps.reviews.services import review_settings_update
|
||||
from apps.reviews.tests.helpers import make_approver
|
||||
from config.errors import ConflictError
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user