Skip to content

Commit

Permalink
Reworked gettingStarted and exercise/serving population
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Apr 1, 2023
1 parent 70e0e73 commit 6378f60
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Sources/Entities/MServing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public extension MServing {
presets.forEach { preset in
userOrder += 1

_ = MServing.create(context,
category: category,
userOrder: userOrder,
name: preset.text,
createdAt: createdAt)
let serving = MServing.create(context,
category: category,
userOrder: userOrder,
name: preset.text,
createdAt: createdAt)

// try task.replaceFields(context, from: preset)
serving.populate(from: preset)
}
}
}
Expand All @@ -72,3 +72,11 @@ public extension MServing {
return Int(Float(calories) * lastIntensity)
}
}

public extension MServing {
func populate(from preset: ServingPreset) {
volume_mL = Float(preset.volume_mL ?? 0)
weight_g = Float(preset.weight_g ?? 0)
calories = Int16(preset.calories)
}
}

0 comments on commit 6378f60

Please sign in to comment.