feat: complete delta sync implementation - add allGames, update callers

- Add allRichGames method to DataProvider
- Update TripCreationViewModel.loadGamesForBrowsing to use allGames (removes 90-day limit)
- Update MockCloudKitService sync methods to use new delta sync signatures
- Update MockAppDataProvider with renamed methods and new allGames/allRichGames
- Fix all callers: ScheduleViewModel, TripCreationViewModel, SuggestedTripsGenerator, GameMatcher
- Update CLAUDE.md documentation with new method names

This completes the delta sync implementation:
- CloudKit sync now uses modificationDate for proper delta sync
- First sync fetches ALL data, subsequent syncs only fetch modified records
- "By Games" mode now shows all available games (not just 90 days)
- All data types (stadiums, teams, games) use consistent delta sync pattern

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-12 11:04:52 -06:00
parent b3ad386d2b
commit 3978429716
8 changed files with 78 additions and 42 deletions

View File

@@ -160,10 +160,13 @@ actor MockCloudKitService {
return games.first { $0.id == id }
}
// MARK: - Sync Fetch Methods
// MARK: - Sync Fetch Methods (Delta Sync Pattern)
func fetchStadiumsForSync() async throws -> [CloudKitService.SyncStadium] {
/// Fetch stadiums for sync - returns all if lastSync is nil, otherwise filters by modification date
func fetchStadiumsForSync(since lastSync: Date?) async throws -> [CloudKitService.SyncStadium] {
try await simulateNetwork()
// Mock doesn't track modification dates, so return all stadiums
// (In production, CloudKit filters by modificationDate)
return stadiums.map { stadium in
CloudKitService.SyncStadium(
stadium: stadium,
@@ -172,9 +175,12 @@ actor MockCloudKitService {
}
}
func fetchTeamsForSync(for sport: Sport) async throws -> [CloudKitService.SyncTeam] {
/// Fetch teams for sync - returns all if lastSync is nil, otherwise filters by modification date
func fetchTeamsForSync(since lastSync: Date?) async throws -> [CloudKitService.SyncTeam] {
try await simulateNetwork()
return teams.filter { $0.sport == sport }.map { team in
// Mock doesn't track modification dates, so return all teams
// (In production, CloudKit filters by modificationDate)
return teams.map { team in
CloudKitService.SyncTeam(
team: team,
canonicalId: team.id,
@@ -183,18 +189,12 @@ actor MockCloudKitService {
}
}
func fetchGamesForSync(
sports: Set<Sport>,
startDate: Date,
endDate: Date
) async throws -> [CloudKitService.SyncGame] {
/// Fetch games for sync - returns all if lastSync is nil, otherwise filters by modification date
func fetchGamesForSync(since lastSync: Date?) async throws -> [CloudKitService.SyncGame] {
try await simulateNetwork()
return games.filter { game in
sports.contains(game.sport) &&
game.dateTime >= startDate &&
game.dateTime <= endDate
}.map { game in
// Mock doesn't track modification dates, so return all games
// (In production, CloudKit filters by modificationDate)
return games.map { game in
CloudKitService.SyncGame(
game: game,
canonicalId: game.id,