diff --git a/SportsTime/Core/Services/CanonicalSyncService.swift b/SportsTime/Core/Services/CanonicalSyncService.swift index e4a8afb..a2c5501 100644 --- a/SportsTime/Core/Services/CanonicalSyncService.swift +++ b/SportsTime/Core/Services/CanonicalSyncService.swift @@ -210,8 +210,8 @@ actor CanonicalSyncService { context: ModelContext, since lastSync: Date? ) async throws -> (updated: Int, skippedIncompatible: Int, skippedOlder: Int) { - // Use sync method that returns canonical IDs directly from CloudKit - let syncStadiums = try await cloudKitService.fetchStadiumsForSync() + // Delta sync: nil = all stadiums, Date = only modified since + let syncStadiums = try await cloudKitService.fetchStadiumsForSync(since: lastSync) var updated = 0 var skippedIncompatible = 0 @@ -240,12 +240,8 @@ actor CanonicalSyncService { context: ModelContext, since lastSync: Date? ) async throws -> (updated: Int, skippedIncompatible: Int, skippedOlder: Int) { - // Use sync method that returns canonical IDs directly from CloudKit - var allSyncTeams: [CloudKitService.SyncTeam] = [] - for sport in Sport.allCases { - let syncTeams = try await cloudKitService.fetchTeamsForSync(for: sport) - allSyncTeams.append(contentsOf: syncTeams) - } + // Single call for all teams with delta sync + let allSyncTeams = try await cloudKitService.fetchTeamsForSync(since: lastSync) var updated = 0 var skippedIncompatible = 0 @@ -275,15 +271,8 @@ actor CanonicalSyncService { context: ModelContext, since lastSync: Date? ) async throws -> (updated: Int, skippedIncompatible: Int, skippedOlder: Int) { - // Use sync method that returns canonical IDs directly from CloudKit - let startDate = lastSync ?? Date() - let endDate = Calendar.current.date(byAdding: .month, value: 6, to: Date()) ?? Date() - - let syncGames = try await cloudKitService.fetchGamesForSync( - sports: Set(Sport.allCases), - startDate: startDate, - endDate: endDate - ) + // Delta sync: nil = all games, Date = only modified since + let syncGames = try await cloudKitService.fetchGamesForSync(since: lastSync) var updated = 0 var skippedIncompatible = 0