Repository navigation
perf(daily): collapse Sudoku week-window to one day-bucketed query (mirror #915) - #924
Merged
Merged
Conversation
…irror #915) #757 wave-6. #915/#919 gave Minesweeper a single day-bucketed week-window query; Sudoku's fetchWeekWindow still fanned out 7 per-day CloudKit round- trips (mode==daily AND status==completed AND puzzleId BEGINSWITH <dayPrefix>). New PersistenceProtocol.fetchCompletedDailyIdsByDay() -> [String: Set<String>] backed by a new gateway case .dailyCompletedAll (mode==daily AND status== completed, no puzzleId prefix) runs ONE query and buckets record puzzleIds by SavedGameStore.extractDailyDay (the 10-char YYYY-MM-DD prefix). fetchWeekWindow calls it once and builds the 7 slots by day-string lookup (empty Set for an absent day), dropping the withThrowingTaskGroup fan-out — the stride(6...0) map is naturally ordered so the explicit re-sort is gone. All 18 protocol conformers (production + every test fake/stub) implement the new method. Key-format equivalence (CR-verified): the bucket key extractDailyDay = puzzleId.prefix(10) and the lookup key UTCDay.string(from:) both emit "%04d-%02d-%02d" — byte-identical, and identical to the dayPrefix the old .dailyCompletedOn predicate filtered on server-side, so per-day results are unchanged. Malformed/non-daily ids drop the same way (server BEGINSWITH miss vs client extractDailyDay==nil). Degrade (throw → report → nil whole strip) and single-day fetchCompletedDailyIds(for:) (AchievementEvaluator/MS guard) are untouched. Snapshot fixtures for snapshotEasyCompletedIPhoneLight/allCompleted were updated to script completedDailyIdsByDate across all 7 window days — NOT re-recorded; the committed baselines are byte-unchanged (the old fake's date-agnostic global default faked the full-streak visual; the fixture now supplies real per-day data reproducing it exactly). Verified: PersistenceKit 79 + SudokuKit Daily 89 (incl. both snapshots vs unchanged baselines + weekWindowFetchIssuesExactlyOneQuery) + GameCenterKit 69 + GameAppKit 46 all pass; swiftlint --strict clean. Dual CR: APPROVE (day- key equivalence + baseline-unmodified directly verified) — a round-1 REJECT was a can't-see-the-impl verification gate, resolved by confirming both keys emit YYYY-MM-DD. Closes #921 Co-Authored-By: Claude Fable 5 <[email protected]>
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
Mirrors #915/#919 onto Sudoku. Sudoku's Daily week-window issued 7 per-day CloudKit queries; new
PersistenceProtocol.fetchCompletedDailyIdsByDay()+ gateway case.dailyCompletedAll(mode==daily AND status==completed, no puzzleId prefix) runs one query and buckets byextractDailyDay.fetchWeekWindowcalls it once. All 18 protocol conformers updated.Why
#757 wave-6 mirror-drift finding — MS got the single-query optimization (#915), Sudoku didn't.
Verification
swiftlint --strictclean.extractDailyDay=puzzleId.prefix(10)and lookup keyUTCDay.string(from:)both emitYYYY-MM-DD— byte-identical, and identical to thedayPrefixthe old.dailyCompletedOnpredicate filtered on. Directly verified by CR + Leader.completedDailyIdsByDateacross all 7 window days to reproduce the committed full-streak PNGs — NOT re-recorded (git statusshows zero__Snapshots__changes).YYYY-MM-DD(three-way: two reviewers + passing snapshot/behavioral tests).Closes #921
🤖 Generated with Claude Code