Fixed a number of sync issues I noticed
All checks were successful
Ascently - Sync Deploy / build-and-push (push) Successful in 2m30s
All checks were successful
Ascently - Sync Deploy / build-and-push (push) Successful in 2m30s
This commit is contained in:
@@ -20,7 +20,6 @@ struct ClimbDataBackup: Codable {
|
||||
let problems: [BackupProblem]
|
||||
let sessions: [BackupClimbSession]
|
||||
let attempts: [BackupAttempt]
|
||||
let deletedItems: [DeletedItem]
|
||||
|
||||
init(
|
||||
exportedAt: String,
|
||||
@@ -29,8 +28,7 @@ struct ClimbDataBackup: Codable {
|
||||
gyms: [BackupGym],
|
||||
problems: [BackupProblem],
|
||||
sessions: [BackupClimbSession],
|
||||
attempts: [BackupAttempt],
|
||||
deletedItems: [DeletedItem] = []
|
||||
attempts: [BackupAttempt]
|
||||
) {
|
||||
self.exportedAt = exportedAt
|
||||
self.version = version
|
||||
@@ -39,7 +37,6 @@ struct ClimbDataBackup: Codable {
|
||||
self.problems = problems
|
||||
self.sessions = sessions
|
||||
self.attempts = attempts
|
||||
self.deletedItems = deletedItems
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +49,7 @@ struct BackupGym: Codable {
|
||||
let difficultySystems: [DifficultySystem]
|
||||
let customDifficultyGrades: [String]
|
||||
let notes: String?
|
||||
let isDeleted: Bool?
|
||||
let createdAt: String
|
||||
let updatedAt: String
|
||||
|
||||
@@ -64,6 +62,8 @@ struct BackupGym: Codable {
|
||||
self.customDifficultyGrades = gym.customDifficultyGrades
|
||||
self.notes = gym.notes
|
||||
|
||||
self.isDeleted = false // Default to false until model is updated
|
||||
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
self.createdAt = formatter.string(from: gym.createdAt)
|
||||
@@ -78,6 +78,7 @@ struct BackupGym: Codable {
|
||||
difficultySystems: [DifficultySystem],
|
||||
customDifficultyGrades: [String] = [],
|
||||
notes: String?,
|
||||
isDeleted: Bool = false,
|
||||
createdAt: String,
|
||||
updatedAt: String
|
||||
) {
|
||||
@@ -88,6 +89,7 @@ struct BackupGym: Codable {
|
||||
self.difficultySystems = difficultySystems
|
||||
self.customDifficultyGrades = customDifficultyGrades
|
||||
self.notes = notes
|
||||
self.isDeleted = isDeleted
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
}
|
||||
@@ -115,6 +117,25 @@ struct BackupGym: Codable {
|
||||
updatedAt: updatedDate
|
||||
)
|
||||
}
|
||||
|
||||
static func createTombstone(id: String, deletedAt: Date) -> BackupGym {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
let dateString = formatter.string(from: deletedAt)
|
||||
|
||||
return BackupGym(
|
||||
id: id,
|
||||
name: "DELETED",
|
||||
location: nil,
|
||||
supportedClimbTypes: [],
|
||||
difficultySystems: [],
|
||||
customDifficultyGrades: [],
|
||||
notes: nil,
|
||||
isDeleted: true,
|
||||
createdAt: dateString,
|
||||
updatedAt: dateString
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Platform-neutral problem representation for backup/restore
|
||||
@@ -131,6 +152,7 @@ struct BackupProblem: Codable {
|
||||
let isActive: Bool
|
||||
let dateSet: String? // ISO 8601 format
|
||||
let notes: String?
|
||||
let isDeleted: Bool?
|
||||
let createdAt: String
|
||||
let updatedAt: String
|
||||
|
||||
@@ -146,6 +168,7 @@ struct BackupProblem: Codable {
|
||||
self.imagePaths = problem.imagePaths.isEmpty ? nil : problem.imagePaths
|
||||
self.isActive = problem.isActive
|
||||
self.notes = problem.notes
|
||||
self.isDeleted = false // Default to false until model is updated
|
||||
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
@@ -167,6 +190,7 @@ struct BackupProblem: Codable {
|
||||
isActive: Bool,
|
||||
dateSet: String?,
|
||||
notes: String?,
|
||||
isDeleted: Bool = false,
|
||||
createdAt: String,
|
||||
updatedAt: String
|
||||
) {
|
||||
@@ -182,6 +206,7 @@ struct BackupProblem: Codable {
|
||||
self.isActive = isActive
|
||||
self.dateSet = dateSet
|
||||
self.notes = notes
|
||||
self.isDeleted = isDeleted
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
}
|
||||
@@ -232,10 +257,35 @@ struct BackupProblem: Codable {
|
||||
isActive: self.isActive,
|
||||
dateSet: self.dateSet,
|
||||
notes: self.notes,
|
||||
isDeleted: self.isDeleted ?? false,
|
||||
createdAt: self.createdAt,
|
||||
updatedAt: self.updatedAt
|
||||
)
|
||||
}
|
||||
|
||||
static func createTombstone(id: String, gymId: String = UUID().uuidString, deletedAt: Date) -> BackupProblem {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
let dateString = formatter.string(from: deletedAt)
|
||||
|
||||
return BackupProblem(
|
||||
id: id,
|
||||
gymId: gymId,
|
||||
name: "DELETED",
|
||||
description: nil,
|
||||
climbType: ClimbType.allCases.first!,
|
||||
difficulty: DifficultyGrade(system: DifficultySystem.allCases.first!, grade: "0"),
|
||||
tags: [],
|
||||
location: nil,
|
||||
imagePaths: nil,
|
||||
isActive: false,
|
||||
dateSet: nil,
|
||||
notes: nil,
|
||||
isDeleted: true,
|
||||
createdAt: dateString,
|
||||
updatedAt: dateString
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Platform-neutral climb session representation for backup/restore
|
||||
@@ -248,6 +298,7 @@ struct BackupClimbSession: Codable {
|
||||
let duration: Int64? // Duration in seconds
|
||||
let status: SessionStatus
|
||||
let notes: String?
|
||||
let isDeleted: Bool?
|
||||
let createdAt: String
|
||||
let updatedAt: String
|
||||
|
||||
@@ -256,6 +307,7 @@ struct BackupClimbSession: Codable {
|
||||
self.gymId = session.gymId.uuidString
|
||||
self.status = session.status
|
||||
self.notes = session.notes
|
||||
self.isDeleted = false // Default to false until model is updated
|
||||
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
@@ -276,6 +328,7 @@ struct BackupClimbSession: Codable {
|
||||
duration: Int64?,
|
||||
status: SessionStatus,
|
||||
notes: String?,
|
||||
isDeleted: Bool = false,
|
||||
createdAt: String,
|
||||
updatedAt: String
|
||||
) {
|
||||
@@ -287,6 +340,7 @@ struct BackupClimbSession: Codable {
|
||||
self.duration = duration
|
||||
self.status = status
|
||||
self.notes = notes
|
||||
self.isDeleted = isDeleted
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
}
|
||||
@@ -321,6 +375,26 @@ struct BackupClimbSession: Codable {
|
||||
updatedAt: updatedDate
|
||||
)
|
||||
}
|
||||
|
||||
static func createTombstone(id: String, gymId: String = UUID().uuidString, deletedAt: Date) -> BackupClimbSession {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
let dateString = formatter.string(from: deletedAt)
|
||||
|
||||
return BackupClimbSession(
|
||||
id: id,
|
||||
gymId: gymId,
|
||||
date: dateString,
|
||||
startTime: nil,
|
||||
endTime: nil,
|
||||
duration: nil,
|
||||
status: .finished,
|
||||
notes: nil,
|
||||
isDeleted: true,
|
||||
createdAt: dateString,
|
||||
updatedAt: dateString
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Platform-neutral attempt representation for backup/restore
|
||||
@@ -334,6 +408,7 @@ struct BackupAttempt: Codable {
|
||||
let duration: Int64? // Duration in seconds
|
||||
let restTime: Int64? // Rest time in seconds
|
||||
let timestamp: String
|
||||
let isDeleted: Bool?
|
||||
let createdAt: String
|
||||
let updatedAt: String?
|
||||
|
||||
@@ -346,6 +421,7 @@ struct BackupAttempt: Codable {
|
||||
self.notes = attempt.notes
|
||||
self.duration = attempt.duration.map { Int64($0) }
|
||||
self.restTime = attempt.restTime.map { Int64($0) }
|
||||
self.isDeleted = false // Default to false until model is updated
|
||||
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
@@ -364,6 +440,7 @@ struct BackupAttempt: Codable {
|
||||
duration: Int64?,
|
||||
restTime: Int64?,
|
||||
timestamp: String,
|
||||
isDeleted: Bool = false,
|
||||
createdAt: String,
|
||||
updatedAt: String?
|
||||
) {
|
||||
@@ -376,6 +453,7 @@ struct BackupAttempt: Codable {
|
||||
self.duration = duration
|
||||
self.restTime = restTime
|
||||
self.timestamp = timestamp
|
||||
self.isDeleted = isDeleted
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
}
|
||||
@@ -412,6 +490,27 @@ struct BackupAttempt: Codable {
|
||||
updatedAt: updatedDate
|
||||
)
|
||||
}
|
||||
|
||||
static func createTombstone(id: String, sessionId: String = UUID().uuidString, problemId: String = UUID().uuidString, deletedAt: Date) -> BackupAttempt {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
let dateString = formatter.string(from: deletedAt)
|
||||
|
||||
return BackupAttempt(
|
||||
id: id,
|
||||
sessionId: sessionId,
|
||||
problemId: problemId,
|
||||
result: AttemptResult.allCases.first!,
|
||||
highestHold: nil,
|
||||
notes: nil,
|
||||
duration: nil,
|
||||
restTime: nil,
|
||||
timestamp: dateString,
|
||||
isDeleted: true,
|
||||
createdAt: dateString,
|
||||
updatedAt: dateString
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Backup Format Errors
|
||||
|
||||
Reference in New Issue
Block a user