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

@@ -48,8 +48,10 @@ final class MockAppDataProvider: ObservableObject {
// MARK: - Call Tracking
private(set) var loadInitialDataCallCount = 0
private(set) var fetchGamesCallCount = 0
private(set) var fetchRichGamesCallCount = 0
private(set) var filterGamesCallCount = 0
private(set) var filterRichGamesCallCount = 0
private(set) var allGamesCallCount = 0
private(set) var allRichGamesCallCount = 0
// MARK: - Initialization
@@ -89,8 +91,10 @@ final class MockAppDataProvider: ObservableObject {
error = nil
errorMessage = nil
loadInitialDataCallCount = 0
fetchGamesCallCount = 0
fetchRichGamesCallCount = 0
filterGamesCallCount = 0
filterRichGamesCallCount = 0
allGamesCallCount = 0
allRichGamesCallCount = 0
config = .default
}
@@ -152,10 +156,10 @@ final class MockAppDataProvider: ObservableObject {
teams.filter { $0.sport == sport }
}
// MARK: - Game Fetching
// MARK: - Game Filtering (Local Queries)
func fetchGames(sports: Set<Sport>, startDate: Date, endDate: Date) async throws -> [Game] {
fetchGamesCallCount += 1
func filterGames(sports: Set<Sport>, startDate: Date, endDate: Date) async throws -> [Game] {
filterGamesCallCount += 1
await simulateLatency()
if config.shouldFailOnFetch {
@@ -169,6 +173,19 @@ final class MockAppDataProvider: ObservableObject {
}.sorted { $0.dateTime < $1.dateTime }
}
func allGames(for sports: Set<Sport>) async throws -> [Game] {
allGamesCallCount += 1
await simulateLatency()
if config.shouldFailOnFetch {
throw DataProviderError.contextNotConfigured
}
return games.filter { game in
sports.contains(game.sport)
}.sorted { $0.dateTime < $1.dateTime }
}
func fetchGame(by id: String) async throws -> Game? {
await simulateLatency()
@@ -179,15 +196,24 @@ final class MockAppDataProvider: ObservableObject {
return gamesById[id]
}
func fetchRichGames(sports: Set<Sport>, startDate: Date, endDate: Date) async throws -> [RichGame] {
fetchRichGamesCallCount += 1
let filteredGames = try await fetchGames(sports: sports, startDate: startDate, endDate: endDate)
func filterRichGames(sports: Set<Sport>, startDate: Date, endDate: Date) async throws -> [RichGame] {
filterRichGamesCallCount += 1
let filteredGames = try await filterGames(sports: sports, startDate: startDate, endDate: endDate)
return filteredGames.compactMap { game in
richGame(from: game)
}
}
func allRichGames(for sports: Set<Sport>) async throws -> [RichGame] {
allRichGamesCallCount += 1
let allFilteredGames = try await allGames(for: sports)
return allFilteredGames.compactMap { game in
richGame(from: game)
}
}
func richGame(from game: Game) -> RichGame? {
guard let homeTeam = teamsById[game.homeTeamId],
let awayTeam = teamsById[game.awayTeamId],
@@ -248,8 +274,8 @@ extension MockAppDataProvider {
stadiumsById[stadium.id] = stadium
}
/// Get all games (for test verification)
func allGames() -> [Game] {
/// Get all stored games (for test verification)
func getAllStoredGames() -> [Game] {
games
}