fix(photo-loader): count terminal items as progress so bar reaches N/N#1195
Merged
Conversation
The batch progress counter (#1152) counted only COMPLETED items, so a batch with any FAILED/CANCELLED item froze at e.g. 2/3 forever — the batch was fully terminal but the bar implied work was still in flight. Count every item in a terminal state (completed/failed/cancelled) as "processed". The terminal set is derived from _PHOTO_ITEM_STATE so it stays in sync if statuses change. total_items is unchanged (all items). Regression test (mutation-verified): a batch of completed+failed+cancelled now reports completed_items == total_items == 3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1
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.
What
Follow-up to #1152. The batch progress counter in
JobsReadModel._from_photo_batchcounted onlyCOMPLETEDitems, so a batch with anyFAILED/CANCELLEDitem froze at e.g.2/3forever — the batch was fully terminal but the counter implied work was still in flight.Fix
completed_itemsnow counts every item in a terminal state (completed / failed / cancelled), so the bar always reachesN/N. The terminal set_PHOTO_TERMINAL_STATUSESis derived from the existing_PHOTO_ITEM_STATEmap (single source of truth — stays in sync if statuses change).total_itemsis unchanged (all items)."Progress" = how many items finished, not how many succeeded — matches the "completeness bar" intent. Per-item success/failure remains visible via the batch status itself.
Tests
New regression test
test_photo_batch_progress_counts_all_terminal_items— a batch of completed+failed+cancelled reportscompleted_items == total_items == 3. Mutation-verified: reverting the prod change tocounts.get(COMPLETED, 0)makes the test fail (1 != 3). Existingtest_photo_batch_read_model_counts_progress(completed+running+pending → 1/3) stays valid.ruffclean; 73 passed locally.Closes #1152
🤖 Generated with Claude Code
https://claude.ai/code/session_01TShpckA1DoLNezbD3txTL1