Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/experimentation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ExperimentResults,
ExperimentStatus,
Metric,
MetricDirection,
WarehouseConnection,
WarehouseConnectionStatus,
WarehouseType,
Expand Down Expand Up @@ -175,6 +176,11 @@ class ExperimentMetricSerializer(serializers.ModelSerializer): # type: ignore[t
)
metric_name = serializers.CharField(source="metric.name", read_only=True)
aggregation = serializers.CharField(source="metric.aggregation", read_only=True)
direction = serializers.ChoiceField(
choices=MetricDirection.choices,
source="metric.direction",
read_only=True,
)

class Meta:
model = ExperimentMetric
Expand All @@ -183,6 +189,7 @@ class Meta:
"metric",
"metric_name",
"aggregation",
"direction",
"expected_direction",
"created_at",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_attach_metric__valid__returns_201(
assert response.status_code == status.HTTP_201_CREATED
data = response.json()
assert data["metric_name"] == "Sessions per User"
assert data["direction"] == "up"
assert data["expected_direction"] == "increase"
assert ExperimentMetric.objects.filter(
experiment=experiment, metric=metric
Expand Down
8 changes: 8 additions & 0 deletions mcp/src/flagsmith_mcp/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4535,6 +4535,14 @@
"type": "string",
"readOnly": true
},
"direction": {
"allOf": [
{
"$ref": "#/components/schemas/DirectionEnum"
}
],
"readOnly": true
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"expected_direction": {
"$ref": "#/components/schemas/ExpectedDirectionEnum"
},
Expand Down
8 changes: 8 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20182,6 +20182,10 @@ components:
aggregation:
type: string
readOnly: true
direction:
allOf:
- $ref: '#/components/schemas/DirectionEnum'
readOnly: true
Comment thread
coderabbitai[bot] marked this conversation as resolved.
expected_direction:
$ref: '#/components/schemas/ExpectedDirectionEnum'
created_at:
Expand Down Expand Up @@ -23687,6 +23691,10 @@ components:
aggregation:
type: string
readOnly: true
direction:
allOf:
- $ref: '#/components/schemas/DirectionEnum'
readOnly: true
expected_direction:
$ref: '#/components/schemas/ExpectedDirectionEnum'
created_at:
Expand Down
Loading