Skip to content

Commit 11734c9

Browse files
fix(preprod): Add deterministic ordering and missing date_updated to admin info endpoint
Add order_by("-date_added") to snapshot comparison and approval queries to ensure deterministic results with .first(). Add missing date_updated field to snapshot_approval serialization for consistency.
1 parent fde15b8 commit 11734c9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/sentry/preprod/api/endpoints/preprod_artifact_admin_info.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,20 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
9797
"base_snapshot_metrics",
9898
)
9999
.filter(head_snapshot_metrics=snapshot_metrics)
100+
.order_by("-date_added")
100101
.first()
101102
)
102103

103104
snapshot_approval = None
104105
if snapshot_metrics:
105-
snapshot_approval = PreprodComparisonApproval.objects.filter(
106-
preprod_artifact_id=head_artifact_id_int,
107-
preprod_feature_type=PreprodComparisonApproval.FeatureType.SNAPSHOTS,
108-
).first()
106+
snapshot_approval = (
107+
PreprodComparisonApproval.objects.filter(
108+
preprod_artifact_id=head_artifact_id_int,
109+
preprod_feature_type=PreprodComparisonApproval.FeatureType.SNAPSHOTS,
110+
)
111+
.order_by("-date_added")
112+
.first()
113+
)
109114

110115
mobile_app_info = preprod_artifact.get_mobile_app_info()
111116

@@ -319,6 +324,11 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
319324
if snapshot_approval.date_added
320325
else None
321326
),
327+
"date_updated": (
328+
snapshot_approval.date_updated.isoformat()
329+
if snapshot_approval.date_updated
330+
else None
331+
),
322332
}
323333
if snapshot_approval
324334
else None

0 commit comments

Comments
 (0)