Skip to content
Merged
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
61 changes: 61 additions & 0 deletions src/sentry/preprod/api/endpoints/preprod_artifact_admin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging

from django.db.models import F
from rest_framework.request import Request
from rest_framework.response import Response

Expand All @@ -15,7 +16,9 @@
InstallablePreprodArtifact,
PreprodArtifact,
PreprodArtifactSizeMetrics,
PreprodComparisonApproval,
)
from sentry.preprod.snapshots.models import PreprodSnapshotComparison, PreprodSnapshotMetrics

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -84,6 +87,51 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
InstallablePreprodArtifact.objects.filter(preprod_artifact_id=head_artifact_id_int)
)

snapshot_metrics = PreprodSnapshotMetrics.objects.filter(
preprod_artifact_id=head_artifact_id_int
).first()

snapshot_comparison = None
if snapshot_metrics:
snapshot_comparison = (
PreprodSnapshotComparison.objects.filter(head_snapshot_metrics=snapshot_metrics)
.order_by("-date_added")
Comment thread
NicoHinderling marked this conversation as resolved.
.values(
"id",
"state",
"error_code",
"error_message",
"images_added",
"images_removed",
"images_changed",
"images_unchanged",
"images_renamed",
"extras",
"date_added",
"date_updated",
base_artifact_id=F("base_snapshot_metrics__preprod_artifact_id"),
)
.first()
)
Comment thread
cursor[bot] marked this conversation as resolved.

snapshot_approval = (
PreprodComparisonApproval.objects.filter(
preprod_artifact_id=head_artifact_id_int,
preprod_feature_type=PreprodComparisonApproval.FeatureType.SNAPSHOTS,
)
.order_by("-date_added")
.values(
"id",
"approval_status",
"approved_at",
"approved_by_id",
"extras",
"date_added",
"date_updated",
)
.first()
)
Comment thread
NicoHinderling marked this conversation as resolved.

mobile_app_info = preprod_artifact.get_mobile_app_info()

artifact_info = {
Expand Down Expand Up @@ -233,6 +281,19 @@ def get(self, request: Request, head_artifact_id: str) -> Response:
}
for installable in installable_artifacts
],
"snapshot_metrics": (
{
"id": snapshot_metrics.id,
Comment thread
NicoHinderling marked this conversation as resolved.
"image_count": snapshot_metrics.image_count,
"extras": snapshot_metrics.extras,
"date_added": snapshot_metrics.date_added,
"date_updated": snapshot_metrics.date_updated,
Comment thread
NicoHinderling marked this conversation as resolved.
}
if snapshot_metrics
else None
),
"snapshot_comparison": snapshot_comparison,
"snapshot_approval": snapshot_approval,
# Extra data
"extras": preprod_artifact.extras,
}
Expand Down
Loading