ref(preprod): Extract shared snapshot status derivation for list and detail endpoints#115604
Open
mtopo27 wants to merge 4 commits into
Open
ref(preprod): Extract shared snapshot status derivation for list and detail endpoints#115604mtopo27 wants to merge 4 commits into
mtopo27 wants to merge 4 commits into
Conversation
…detail endpoints Both the snapshot list and detail API endpoints independently derived comparison_state and approval_status with duplicated logic that had diverged (casing, grace period handling, auto_approved representation). This extracts a shared derive_snapshot_status() function and adds flat comparison_state, approval_status, comparison_error_message, and approvers fields to the detail response. Refs EME-1149
…tus type aliases Reduce three separate PreprodSnapshotComparison queries in the detail endpoint to a single fetch, deriving latest_comparison, successful comparison, and pending/failed state from the same queryset. Extract ComparisonStateLiteral and ApprovalStatusLiteral type aliases to eliminate duplicate Literal definitions across models. Trim redundant unit tests in test_snapshot_status.
NicoHinderling
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The snapshot list and detail API endpoints independently derived
comparison_stateandapproval_statuswith duplicated logic that had diverged — different casing (UPPER vs lower), missing grace period /no_base_buildon the detail endpoint, nocomparison_error_messageon detail, andauto_approvedrepresented as a string vs boolean. This extracts the derivation into a single shared function and adds flat status fields to the detail response so both endpoints speak the same language.Shared derivation function
derive_snapshot_status()insnapshot_status.pytakes pre-fetched data (latest comparison, latest approval, grace period inputs) and returnscomparison_state,approval_status, andcomparison_error_message. Bothto_snapshot_comparison_info()(list) and the detail endpoint'sget()now delegate to it. No ORM queries in the shared function — callers assemble input from their own data.Flat fields on the detail response
SnapshotDetailsApiResponsegains four additive fields:comparison_state,approval_status,comparison_error_message, andapprovers(hoisted fromapproval_info). Existing split fields (comparison_type,comparison_run_info,approval_info) are unchanged — deprecation is a separate effort. The detail endpoint also gains grace period /no_base_buildlogic it was previously missing, closing a behavioral gap with the list API.Refs EME-1149