Skip to content

Commit 592c7d3

Browse files
feat(preprod): Add comparisonRunInfo data to response + new extra frontend models
1 parent 3d9366e commit 592c7d3

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class SnapshotDiffSection(StrEnum):
1212
ADDED = "added"
1313
REMOVED = "removed"
14+
RENAMED = "renamed"
1415
CHANGED = "changed"
1516
UNCHANGED = "unchanged"
1617
ERRORED = "errored"
@@ -34,6 +35,12 @@ class SnapshotDiffPair(BaseModel):
3435
diff: float | None = None
3536

3637

38+
class SnapshotComparisonRunInfo(BaseModel):
39+
state: str | None = None
40+
completed_at: str | None = None
41+
duration_ms: int | None = None
42+
43+
3744
class SnapshotDetailsApiResponse(BaseModel):
3845
head_artifact_id: str
3946
base_artifact_id: str | None = None # Only present for diffs
@@ -51,6 +58,9 @@ class SnapshotDetailsApiResponse(BaseModel):
5158
removed: list[SnapshotImageResponse] = []
5259
removed_count: int = 0
5360

61+
renamed: list[SnapshotImageResponse] = []
62+
renamed_count: int = 0
63+
5464
changed: list[SnapshotDiffPair] = []
5565
changed_count: int = 0
5666

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

73+
comparison_run_info: SnapshotComparisonRunInfo | None = None
74+
6375

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

src/sentry/preprod/snapshots/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ComparisonSummary(BaseModel):
4141
unchanged: int
4242
added: int
4343
removed: int
44-
errored: int
44+
errored: int = 0
4545

4646

4747
class ComparisonManifest(BaseModel):

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

Lines changed: 22 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;
@@ -33,6 +41,20 @@ export interface SnapshotDetailsApiResponse {
3341
changed_count: number;
3442
removed: SnapshotImage[];
3543
removed_count: number;
44+
renamed?: SnapshotImage[];
45+
renamed_count?: number;
3646
unchanged: SnapshotImage[];
3747
unchanged_count: number;
3848
}
49+
50+
export type ComparisonState = 'pending' | 'processing' | 'success' | 'failed';
51+
52+
export type DiffStatus = 'changed' | 'added' | 'removed' | 'renamed' | 'unchanged';
53+
54+
export type SidebarItem =
55+
| {type: 'solo'; name: string; images: SnapshotImage[]}
56+
| {type: 'changed'; name: string; pair: SnapshotDiffPair}
57+
| {type: 'added'; name: string; image: SnapshotImage}
58+
| {type: 'removed'; name: string; image: SnapshotImage}
59+
| {type: 'renamed'; name: string; image: SnapshotImage}
60+
| {type: 'unchanged'; name: string; image: SnapshotImage};

0 commit comments

Comments
 (0)