Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Exercise {
def unit() {
String unit = "min"
if (tags.contains("(floor_count)")) {
unit = "floors"
} else if (tags.contains("(step_count)")) {
unit = "steps"
}
}
}
class ExerciseEntry {
def unit() {
exercise.unit()
}
}
// Fragmento original refactorizado
List <Map> exerciseEntries = []
dayEntry.exercisesEntries.each { ExerciseEntry exerciseEntry ->
Map exerciseEntryInfo = [
exercise_id: exercise.exerciseId,
value: exerciseEntry.minutes,
unit: exerciseEntry.unit()
]
exerciseEntries.add(exerciseEntryInfo)
}
resposeData.movement = exerciseEntries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment