Skip to content

Commit fde15b8

Browse files
feat(preprod): Add snapshot details to admin info endpoint
Add snapshot metrics, comparison, and approval data to the preprod artifact admin info endpoint for debugging visibility.
1 parent 88ba368 commit fde15b8

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

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

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
InstallablePreprodArtifact,
1616
PreprodArtifact,
1717
PreprodArtifactSizeMetrics,
18+
PreprodComparisonApproval,
1819
)
20+
from sentry.preprod.snapshots.models import PreprodSnapshotComparison, PreprodSnapshotMetrics
1921

2022
logger = logging.getLogger(__name__)
2123

@@ -84,6 +86,27 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
8486
InstallablePreprodArtifact.objects.filter(preprod_artifact_id=head_artifact_id_int)
8587
)
8688

89+
snapshot_metrics = PreprodSnapshotMetrics.objects.filter(
90+
preprod_artifact_id=head_artifact_id_int
91+
).first()
92+
93+
snapshot_comparison = None
94+
if snapshot_metrics:
95+
snapshot_comparison = (
96+
PreprodSnapshotComparison.objects.select_related(
97+
"base_snapshot_metrics",
98+
)
99+
.filter(head_snapshot_metrics=snapshot_metrics)
100+
.first()
101+
)
102+
103+
snapshot_approval = None
104+
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()
109+
87110
mobile_app_info = preprod_artifact.get_mobile_app_info()
88111

89112
artifact_info = {
@@ -233,6 +256,73 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
233256
}
234257
for installable in installable_artifacts
235258
],
259+
# Snapshot data
260+
"snapshot_metrics": (
261+
{
262+
"id": snapshot_metrics.id,
263+
"image_count": snapshot_metrics.image_count,
264+
"extras": snapshot_metrics.extras,
265+
"date_added": (
266+
snapshot_metrics.date_added.isoformat()
267+
if snapshot_metrics.date_added
268+
else None
269+
),
270+
"date_updated": (
271+
snapshot_metrics.date_updated.isoformat()
272+
if snapshot_metrics.date_updated
273+
else None
274+
),
275+
}
276+
if snapshot_metrics
277+
else None
278+
),
279+
"snapshot_comparison": (
280+
{
281+
"id": snapshot_comparison.id,
282+
"state": snapshot_comparison.state,
283+
"error_code": snapshot_comparison.error_code,
284+
"error_message": snapshot_comparison.error_message,
285+
"base_artifact_id": snapshot_comparison.base_snapshot_metrics.preprod_artifact_id,
286+
"images_added": snapshot_comparison.images_added,
287+
"images_removed": snapshot_comparison.images_removed,
288+
"images_changed": snapshot_comparison.images_changed,
289+
"images_unchanged": snapshot_comparison.images_unchanged,
290+
"images_renamed": snapshot_comparison.images_renamed,
291+
"extras": snapshot_comparison.extras,
292+
"date_added": (
293+
snapshot_comparison.date_added.isoformat()
294+
if snapshot_comparison.date_added
295+
else None
296+
),
297+
"date_updated": (
298+
snapshot_comparison.date_updated.isoformat()
299+
if snapshot_comparison.date_updated
300+
else None
301+
),
302+
}
303+
if snapshot_comparison
304+
else None
305+
),
306+
"snapshot_approval": (
307+
{
308+
"id": snapshot_approval.id,
309+
"approval_status": snapshot_approval.approval_status,
310+
"approved_at": (
311+
snapshot_approval.approved_at.isoformat()
312+
if snapshot_approval.approved_at
313+
else None
314+
),
315+
"approved_by_id": snapshot_approval.approved_by_id,
316+
"extras": snapshot_approval.extras,
317+
"date_added": (
318+
snapshot_approval.date_added.isoformat()
319+
if snapshot_approval.date_added
320+
else None
321+
),
322+
}
323+
if snapshot_approval
324+
else None
325+
),
236326
# Extra data
237327
"extras": preprod_artifact.extras,
238328
}

0 commit comments

Comments
 (0)