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

@@ -197,6 +197,20 @@ final class AppDataProvider: ObservableObject {
}
}
/// Get all games with full team and stadium data (no date filtering)
func allRichGames(for sports: Set<Sport>) async throws -> [RichGame] {
let games = try await allGames(for: sports)
return games.compactMap { game in
guard let homeTeam = teamsById[game.homeTeamId],
let awayTeam = teamsById[game.awayTeamId],
let stadium = stadiumsById[game.stadiumId] else {
return nil
}
return RichGame(game: game, homeTeam: homeTeam, awayTeam: awayTeam, stadium: stadium)
}
}
func richGame(from game: Game) -> RichGame? {
guard let homeTeam = teamsById[game.homeTeamId],
let awayTeam = teamsById[game.awayTeamId],

View File

@@ -398,7 +398,7 @@ final class GameMatcher {
let sports: Set<Sport> = sport != nil ? [sport!] : Set(Sport.allCases)
do {
let allGames = try await dataProvider.fetchGames(sports: sports, startDate: startDate, endDate: endDate)
let allGames = try await dataProvider.filterGames(sports: sports, startDate: startDate, endDate: endDate)
// Filter by stadium
let games = allGames.filter { $0.stadiumId == stadium.id }

View File

@@ -104,9 +104,9 @@ final class SuggestedTripsGenerator {
}
do {
// Fetch all games in the window
// Filter all games in the window
let allSports = Set(Sport.supported)
let games = try await dataProvider.fetchGames(
let games = try await dataProvider.filterGames(
sports: allSports,
startDate: startDate,
endDate: endDate

View File

@@ -95,7 +95,7 @@ final class ScheduleViewModel {
return
}
games = try await dataProvider.fetchRichGames(
games = try await dataProvider.filterRichGames(
sports: selectedSports,
startDate: startDate,
endDate: endDate

View File

@@ -260,8 +260,8 @@ final class TripCreationViewModel {
stadiums[stadium.id] = stadium
}
// Fetch games
games = try await dataProvider.fetchGames(
// Filter games within date range
games = try await dataProvider.filterGames(
sports: selectedSports,
startDate: startDate,
endDate: endDate
@@ -488,13 +488,8 @@ final class TripCreationViewModel {
stadiums[stadium.id] = stadium
}
// Fetch games for next 90 days for browsing
let browseEndDate = Calendar.current.date(byAdding: .day, value: 90, to: Date()) ?? endDate
games = try await dataProvider.fetchGames(
sports: selectedSports,
startDate: Date(),
endDate: browseEndDate
)
// Fetch all games for browsing (no date filter)
games = try await dataProvider.allGames(for: selectedSports)
// Build rich games for display
availableGames = games.compactMap { game -> RichGame? in