Set primary activity to always be true

This commit is contained in:
Christoph Hagen 2024-02-01 21:53:56 +01:00
parent 94fc10f204
commit 42e95f9ff9
2 changed files with 3 additions and 6 deletions

View File

@ -75,12 +75,9 @@ extension Workout {
try event.insert(in: database, dataId: dataId) try event.insert(in: database, dataId: dataId)
} }
if let activity = element.activities.first { for activity in element.activities {
try WorkoutActivityTable.insert(activity, isPrimaryActivity: true, dataId: dataId, in: database) try WorkoutActivityTable.insert(activity, isPrimaryActivity: true, dataId: dataId, in: database)
} }
for activity in element.activities.dropFirst() {
try WorkoutActivityTable.insert(activity, isPrimaryActivity: false, dataId: dataId, in: database)
}
for (key, value) in element.metadata { for (key, value) in element.metadata {
try Metadata.insert(value, for: key, of: dataId, in: database) try Metadata.insert(value, for: key, of: dataId, in: database)

View File

@ -90,7 +90,7 @@ enum WorkoutActivityTable {
try database.run(table.insert( try database.run(table.insert(
columnUUID <- (element.externalUUID ?? element.uuid).uuidString.data(using: .utf8)!, columnUUID <- (element.externalUUID ?? element.uuid).uuidString.data(using: .utf8)!,
columnOwnerId <- dataId, columnOwnerId <- dataId,
columnIsPrimaryActivity <- isPrimaryActivity, columnIsPrimaryActivity <- isPrimaryActivity, // Seems to always be 1
columnActivityType <- Int(element.workoutConfiguration.activityType.rawValue), columnActivityType <- Int(element.workoutConfiguration.activityType.rawValue),
columnLocationType <- element.workoutConfiguration.locationType.rawValue, columnLocationType <- element.workoutConfiguration.locationType.rawValue,
columnSwimmingLocationType <- element.workoutConfiguration.swimmingLocationType.rawValue, columnSwimmingLocationType <- element.workoutConfiguration.swimmingLocationType.rawValue,