Add machine comfort settings and tighten the document schemas
Machine-based exercises now carry ordered name/value comfort settings (seat height, back-rest position, ...) on both ExerciseDocument and, as a plan-time snapshot, WorkoutLogDocument — the optional array doubles as the machine flag. Editable from the exercise editor's new Machine section and from the workout row's settings sheet, whose mid-workout edits write back to the originating split (workout saved first, so seed clone-on-edit repointing can't clobber the log edit). Schema tightening rides the same rev: splits bump to v2 (weight-reminder fields and the unused exercise category removed), workouts to v3 (the derived `completed` flag removed; status is the single source). Starter seeds regenerated at v2 with unchanged ULIDs; SwiftData cache schema bumped to rebuild. SCHEMA.md documents the shapes. Claude-Session: https://claude.ai/code/session_01LEoff8bXGBS83tK1c55Mf7
This commit is contained in:
@@ -30,18 +30,20 @@ enum ScreenshotSeed {
|
||||
func daysAgo(_ n: Int) -> Date { cal.date(byAdding: .day, value: -n, to: today) ?? today }
|
||||
|
||||
// ---- Splits (with exercises) ------------------------------------------
|
||||
// Names match the bundled Exercise Library rigs so every screen shows its
|
||||
// animated figure (an unknown name would leave the figure slot empty).
|
||||
let splits: [(String, String, String, [(String, Int, Int, Int)])] = [
|
||||
("Upper Body", "purple", "dumbbell.fill", [
|
||||
("Bench Press", 4, 10, 135), ("Overhead Press", 4, 10, 75),
|
||||
("Lat Pulldown", 4, 12, 120), ("Bicep Curl", 3, 12, 30),
|
||||
("Upper Body", "blue", "figure.strengthtraining.traditional", [
|
||||
("Lat Pull Down", 4, 10, 110), ("Seated Row", 4, 10, 90),
|
||||
("Shoulder Press", 4, 10, 40), ("Arm Curl", 3, 12, 40),
|
||||
]),
|
||||
("Lower Body", "blue", "figure.strengthtraining.traditional", [
|
||||
("Back Squat", 5, 5, 185), ("Romanian Deadlift", 4, 8, 155),
|
||||
("Leg Press", 4, 12, 270), ("Calf Raise", 4, 15, 90),
|
||||
("Lower Body", "green", "figure.run", [
|
||||
("Leg Press", 4, 10, 140), ("Leg Curl", 4, 10, 40),
|
||||
("Leg Extension", 4, 10, 80), ("Calfs", 4, 15, 100),
|
||||
]),
|
||||
("Core", "orange", "figure.core.training", [
|
||||
("Plank", 3, 0, 0), ("Hanging Leg Raise", 3, 12, 0),
|
||||
("Cable Crunch", 3, 15, 50),
|
||||
("Plank", 3, 0, 0), ("Abdominal", 4, 10, 40),
|
||||
("Rotary", 4, 10, 40),
|
||||
]),
|
||||
]
|
||||
|
||||
@@ -53,8 +55,7 @@ enum ScreenshotSeed {
|
||||
let isDuration = e.0 == "Plank"
|
||||
let ex = Exercise(id: ULID.make(), name: e.0, order: eIndex, sets: e.1, reps: e.2,
|
||||
weight: e.3, loadType: (isDuration ? LoadType.duration : .weight).rawValue,
|
||||
durationTotalSeconds: isDuration ? 45 : 0, weightLastUpdated: today,
|
||||
weightReminderTimeIntervalWeeks: 2)
|
||||
durationTotalSeconds: isDuration ? 45 : 0)
|
||||
ex.split = split
|
||||
context.insert(ex)
|
||||
}
|
||||
@@ -62,19 +63,19 @@ enum ScreenshotSeed {
|
||||
|
||||
let upper = splits[0]
|
||||
|
||||
// ---- Past finished sessions (Bench Press trend for the chart) ----------
|
||||
let benchTrend = [115, 120, 125, 130]
|
||||
for (i, w) in benchTrend.enumerated() {
|
||||
let date = daysAgo((benchTrend.count - i) * 4)
|
||||
// ---- Past finished sessions (Lat Pull Down trend for the chart) --------
|
||||
let liftTrend = [95, 100, 105, 110]
|
||||
for (i, w) in liftTrend.enumerated() {
|
||||
let date = daysAgo((liftTrend.count - i) * 4)
|
||||
let workout = Workout(id: ULID.make(), splitID: nil, splitName: upper.0, start: date,
|
||||
end: date.addingTimeInterval(2400), statusRaw: WorkoutStatus.completed.rawValue,
|
||||
createdAt: date, updatedAt: date, jsonRelativePath: "")
|
||||
context.insert(workout)
|
||||
for (eIndex, e) in upper.3.enumerated() {
|
||||
let weight = e.0 == "Bench Press" ? w : e.3
|
||||
let weight = e.0 == "Lat Pull Down" ? w : e.3
|
||||
let log = WorkoutLog(id: ULID.make(), exerciseName: e.0, order: eIndex, sets: e.1,
|
||||
reps: e.2, weight: weight, loadType: LoadType.weight.rawValue,
|
||||
durationTotalSeconds: 0, currentStateIndex: e.1, completed: true,
|
||||
durationTotalSeconds: 0, currentStateIndex: e.1,
|
||||
statusRaw: WorkoutStatus.completed.rawValue, notes: nil, date: date)
|
||||
log.workout = workout
|
||||
context.insert(log)
|
||||
@@ -86,13 +87,13 @@ enum ScreenshotSeed {
|
||||
end: nil, statusRaw: WorkoutStatus.inProgress.rawValue,
|
||||
createdAt: today, updatedAt: today, jsonRelativePath: "")
|
||||
context.insert(workout)
|
||||
// Bench Press done, Overhead Press partway, the rest to go.
|
||||
// Lat Pull Down done, Seated Row partway, the rest to go.
|
||||
let progress = [(4, WorkoutStatus.completed), (2, .inProgress), (0, .notStarted), (0, .notStarted)]
|
||||
for (eIndex, e) in upper.3.enumerated() {
|
||||
let (idx, status) = progress[eIndex]
|
||||
let log = WorkoutLog(id: ULID.make(), exerciseName: e.0, order: eIndex, sets: e.1, reps: e.2,
|
||||
weight: e.0 == "Bench Press" ? 135 : e.3, loadType: LoadType.weight.rawValue,
|
||||
durationTotalSeconds: 0, currentStateIndex: idx, completed: status == .completed,
|
||||
weight: e.0 == "Lat Pull Down" ? 110 : e.3, loadType: LoadType.weight.rawValue,
|
||||
durationTotalSeconds: 0, currentStateIndex: idx,
|
||||
statusRaw: status.rawValue, notes: nil, date: today)
|
||||
log.workout = workout
|
||||
context.insert(log)
|
||||
|
||||
Reference in New Issue
Block a user