Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/sentry/preprod/api/endpoints/preprod_artifact_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,19 @@ def on_results(images: list[SnapshotImageResponse]) -> dict[str, Any]:
)

result = response.dict()
result["org_id"] = str(organization.id)
result["project_id"] = str(artifact.project_id)
result["comparison_type"] = comparison_type

run_info: dict[str, Any] = {}
if comparison_state is not None:
result["comparison_state"] = comparison_state
run_info["state"] = comparison_state
elif comparison is not None:
run_info["state"] = PreprodSnapshotComparison.State(comparison.state).name.lower()
run_info["completed_at"] = comparison.date_updated.isoformat()
duration = comparison.date_updated - comparison.date_added
run_info["duration_ms"] = int(duration.total_seconds() * 1000)
if run_info:
result["comparison_run_info"] = run_info

return result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class SnapshotDiffSection(StrEnum):
ADDED = "added"
REMOVED = "removed"
RENAMED = "renamed"
CHANGED = "changed"
UNCHANGED = "unchanged"
ERRORED = "errored"
Expand All @@ -34,6 +35,12 @@ class SnapshotDiffPair(BaseModel):
diff: float | None = None


class SnapshotComparisonRunInfo(BaseModel):
state: str | None = None
completed_at: str | None = None
duration_ms: int | None = None


class SnapshotDetailsApiResponse(BaseModel):
head_artifact_id: str
base_artifact_id: str | None = None # Only present for diffs
Expand All @@ -51,6 +58,9 @@ class SnapshotDetailsApiResponse(BaseModel):
removed: list[SnapshotImageResponse] = []
removed_count: int = 0

renamed: list[SnapshotImageResponse] = []
renamed_count: int = 0

changed: list[SnapshotDiffPair] = []
changed_count: int = 0

Expand All @@ -60,5 +70,7 @@ class SnapshotDetailsApiResponse(BaseModel):
errored: list[SnapshotDiffPair] = []
errored_count: int = 0

comparison_run_info: SnapshotComparisonRunInfo | None = None


# TODO: POST request in the future when we migrate away from current schemas
Loading