Stabilize beta release with warning cleanup and edge-case fixes
This commit is contained in:
@@ -224,6 +224,51 @@ actor CloudKitService {
|
||||
let stadiumCanonicalId: String?
|
||||
}
|
||||
|
||||
struct SyncLeagueStructure: Sendable {
|
||||
let id: String
|
||||
let sport: String
|
||||
let structureTypeRaw: String
|
||||
let name: String
|
||||
let abbreviation: String?
|
||||
let parentId: String?
|
||||
let displayOrder: Int
|
||||
let schemaVersion: Int
|
||||
let lastModified: Date
|
||||
}
|
||||
|
||||
struct SyncTeamAlias: Sendable {
|
||||
let id: String
|
||||
let teamCanonicalId: String
|
||||
let aliasTypeRaw: String
|
||||
let aliasValue: String
|
||||
let validFrom: Date?
|
||||
let validUntil: Date?
|
||||
let schemaVersion: Int
|
||||
let lastModified: Date
|
||||
}
|
||||
|
||||
struct SyncStadiumAlias: Sendable {
|
||||
let aliasName: String
|
||||
let stadiumCanonicalId: String
|
||||
let validFrom: Date?
|
||||
let validUntil: Date?
|
||||
let schemaVersion: Int
|
||||
let lastModified: Date
|
||||
}
|
||||
|
||||
struct SyncSport: Sendable {
|
||||
let id: String
|
||||
let abbreviation: String
|
||||
let displayName: String
|
||||
let iconName: String
|
||||
let colorHex: String
|
||||
let seasonStartMonth: Int
|
||||
let seasonEndMonth: Int
|
||||
let isActive: Bool
|
||||
let schemaVersion: Int
|
||||
let lastModified: Date
|
||||
}
|
||||
|
||||
// MARK: - Availability Check
|
||||
|
||||
func isAvailable() async -> Bool {
|
||||
@@ -579,7 +624,7 @@ actor CloudKitService {
|
||||
/// - Parameters:
|
||||
/// - lastSync: If nil, fetches all records. If provided, fetches only records modified since that date.
|
||||
/// - cancellationToken: Optional token to check for cancellation between pages
|
||||
func fetchLeagueStructureChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [LeagueStructureModel] {
|
||||
func fetchLeagueStructureChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [SyncLeagueStructure] {
|
||||
let log = SyncLogger.shared
|
||||
let predicate: NSPredicate
|
||||
if let deltaStart = effectiveDeltaStartDate(lastSync) {
|
||||
@@ -594,11 +639,23 @@ actor CloudKitService {
|
||||
let records = try await fetchAllRecords(matching: query, cancellationToken: cancellationToken)
|
||||
log.log("☁️ [CK] Received \(records.count) league structure records from CloudKit")
|
||||
|
||||
var parsed: [LeagueStructureModel] = []
|
||||
var parsed: [SyncLeagueStructure] = []
|
||||
var skipped = 0
|
||||
for record in records {
|
||||
if let model = CKLeagueStructure(record: record).toModel() {
|
||||
parsed.append(model)
|
||||
parsed.append(
|
||||
SyncLeagueStructure(
|
||||
id: model.id,
|
||||
sport: model.sport,
|
||||
structureTypeRaw: model.structureTypeRaw,
|
||||
name: model.name,
|
||||
abbreviation: model.abbreviation,
|
||||
parentId: model.parentId,
|
||||
displayOrder: model.displayOrder,
|
||||
schemaVersion: model.schemaVersion,
|
||||
lastModified: model.lastModified
|
||||
)
|
||||
)
|
||||
} else {
|
||||
skipped += 1
|
||||
}
|
||||
@@ -618,7 +675,7 @@ actor CloudKitService {
|
||||
/// - Parameters:
|
||||
/// - lastSync: If nil, fetches all records. If provided, fetches only records modified since that date.
|
||||
/// - cancellationToken: Optional token to check for cancellation between pages
|
||||
func fetchTeamAliasChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [TeamAlias] {
|
||||
func fetchTeamAliasChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [SyncTeamAlias] {
|
||||
let log = SyncLogger.shared
|
||||
let predicate: NSPredicate
|
||||
if let deltaStart = effectiveDeltaStartDate(lastSync) {
|
||||
@@ -633,11 +690,22 @@ actor CloudKitService {
|
||||
let records = try await fetchAllRecords(matching: query, cancellationToken: cancellationToken)
|
||||
log.log("☁️ [CK] Received \(records.count) team alias records from CloudKit")
|
||||
|
||||
var parsed: [TeamAlias] = []
|
||||
var parsed: [SyncTeamAlias] = []
|
||||
var skipped = 0
|
||||
for record in records {
|
||||
if let model = CKTeamAlias(record: record).toModel() {
|
||||
parsed.append(model)
|
||||
parsed.append(
|
||||
SyncTeamAlias(
|
||||
id: model.id,
|
||||
teamCanonicalId: model.teamCanonicalId,
|
||||
aliasTypeRaw: model.aliasTypeRaw,
|
||||
aliasValue: model.aliasValue,
|
||||
validFrom: model.validFrom,
|
||||
validUntil: model.validUntil,
|
||||
schemaVersion: model.schemaVersion,
|
||||
lastModified: model.lastModified
|
||||
)
|
||||
)
|
||||
} else {
|
||||
skipped += 1
|
||||
}
|
||||
@@ -657,7 +725,7 @@ actor CloudKitService {
|
||||
/// - Parameters:
|
||||
/// - lastSync: If nil, fetches all records. If provided, fetches only records modified since that date.
|
||||
/// - cancellationToken: Optional token to check for cancellation between pages
|
||||
func fetchStadiumAliasChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [StadiumAlias] {
|
||||
func fetchStadiumAliasChanges(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [SyncStadiumAlias] {
|
||||
let log = SyncLogger.shared
|
||||
let predicate: NSPredicate
|
||||
if let deltaStart = effectiveDeltaStartDate(lastSync) {
|
||||
@@ -672,11 +740,20 @@ actor CloudKitService {
|
||||
let records = try await fetchAllRecords(matching: query, cancellationToken: cancellationToken)
|
||||
log.log("☁️ [CK] Received \(records.count) stadium alias records from CloudKit")
|
||||
|
||||
var parsed: [StadiumAlias] = []
|
||||
var parsed: [SyncStadiumAlias] = []
|
||||
var skipped = 0
|
||||
for record in records {
|
||||
if let model = CKStadiumAlias(record: record).toModel() {
|
||||
parsed.append(model)
|
||||
parsed.append(
|
||||
SyncStadiumAlias(
|
||||
aliasName: model.aliasName,
|
||||
stadiumCanonicalId: model.stadiumCanonicalId,
|
||||
validFrom: model.validFrom,
|
||||
validUntil: model.validUntil,
|
||||
schemaVersion: model.schemaVersion,
|
||||
lastModified: model.lastModified
|
||||
)
|
||||
)
|
||||
} else {
|
||||
skipped += 1
|
||||
}
|
||||
@@ -698,7 +775,7 @@ actor CloudKitService {
|
||||
/// - Parameters:
|
||||
/// - lastSync: If nil, fetches all sports. If provided, fetches only sports modified since that date.
|
||||
/// - cancellationToken: Optional token to check for cancellation between pages
|
||||
func fetchSportsForSync(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [CanonicalSport] {
|
||||
func fetchSportsForSync(since lastSync: Date?, cancellationToken: SyncCancellationToken? = nil) async throws -> [SyncSport] {
|
||||
let log = SyncLogger.shared
|
||||
let predicate: NSPredicate
|
||||
if let deltaStart = effectiveDeltaStartDate(lastSync) {
|
||||
@@ -713,11 +790,24 @@ actor CloudKitService {
|
||||
let records = try await fetchAllRecords(matching: query, cancellationToken: cancellationToken)
|
||||
log.log("☁️ [CK] Received \(records.count) sport records from CloudKit")
|
||||
|
||||
var parsed: [CanonicalSport] = []
|
||||
var parsed: [SyncSport] = []
|
||||
var skipped = 0
|
||||
for record in records {
|
||||
if let sport = CKSport(record: record).toCanonical() {
|
||||
parsed.append(sport)
|
||||
parsed.append(
|
||||
SyncSport(
|
||||
id: sport.id,
|
||||
abbreviation: sport.abbreviation,
|
||||
displayName: sport.displayName,
|
||||
iconName: sport.iconName,
|
||||
colorHex: sport.colorHex,
|
||||
seasonStartMonth: sport.seasonStartMonth,
|
||||
seasonEndMonth: sport.seasonEndMonth,
|
||||
isActive: sport.isActive,
|
||||
schemaVersion: sport.schemaVersion,
|
||||
lastModified: sport.lastModified
|
||||
)
|
||||
)
|
||||
} else {
|
||||
skipped += 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user