Skip to content

Commit 8519219

Browse files
feat(preprod): Add comparisonRunInfo data to response + new extra frontend models
1 parent 580e911 commit 8519219

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,19 @@ def on_results(images: list[SnapshotImageResponse]) -> dict[str, Any]:
258258
)
259259

260260
result = response.dict()
261-
result["org_id"] = str(organization.id)
262261
result["project_id"] = str(artifact.project_id)
263262
result["comparison_type"] = comparison_type
263+
264+
run_info: dict[str, Any] = {}
264265
if comparison_state is not None:
265-
result["comparison_state"] = comparison_state
266+
run_info["state"] = comparison_state
267+
if comparison is not None:
268+
run_info["state"] = PreprodSnapshotComparison.State(comparison.state).name.lower()
269+
run_info["completed_at"] = comparison.date_updated.isoformat()
270+
duration = comparison.date_updated - comparison.date_added
271+
run_info["duration_ms"] = int(duration.total_seconds() * 1000)
272+
if run_info:
273+
result["comparison_run_info"] = run_info
266274

267275
return result
268276

src/sentry/preprod/api/models/snapshots/project_preprod_snapshot_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class SnapshotDiffPair(BaseModel):
3434
diff: float | None = None
3535

3636

37+
class SnapshotComparisonRunInfo(BaseModel):
38+
state: str | None = None
39+
completed_at: str | None = None
40+
duration_ms: int | None = None
41+
42+
3743
class SnapshotDetailsApiResponse(BaseModel):
3844
head_artifact_id: str
3945
base_artifact_id: str | None = None # Only present for diffs
@@ -60,5 +66,7 @@ class SnapshotDetailsApiResponse(BaseModel):
6066
errored: list[SnapshotDiffPair] = []
6167
errored_count: int = 0
6268

69+
comparison_run_info: SnapshotComparisonRunInfo | None = None
70+
6371

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

static/app/views/preprod/types/snapshotTypes.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export interface SnapshotDiffPair {
1616
head_image: SnapshotImage;
1717
}
1818

19+
export interface SnapshotComparisonRunInfo {
20+
completed_at?: string;
21+
duration_ms?: number;
22+
state?: ComparisonState;
23+
}
24+
1925
export interface SnapshotDetailsApiResponse {
2026
comparison_type: 'solo' | 'diff';
2127
head_artifact_id: string;
@@ -25,6 +31,8 @@ export interface SnapshotDetailsApiResponse {
2531
state: string;
2632
vcs_info: BuildDetailsVcsInfo;
2733

34+
comparison_run_info?: SnapshotComparisonRunInfo;
35+
2836
// Diff fields
2937
added: SnapshotImage[];
3038
added_count: number;
@@ -36,3 +44,14 @@ export interface SnapshotDetailsApiResponse {
3644
unchanged: SnapshotImage[];
3745
unchanged_count: number;
3846
}
47+
48+
export type ComparisonState = 'pending' | 'processing' | 'success' | 'failed';
49+
50+
export type DiffStatus = 'changed' | 'added' | 'removed' | 'unchanged';
51+
52+
export type SidebarItem =
53+
| {type: 'solo'; name: string; images: SnapshotImage[]}
54+
| {type: 'changed'; name: string; pair: SnapshotDiffPair}
55+
| {type: 'added'; name: string; image: SnapshotImage}
56+
| {type: 'removed'; name: string; image: SnapshotImage}
57+
| {type: 'unchanged'; name: string; image: SnapshotImage};

0 commit comments

Comments
 (0)