-
-
Save Gazer/b73eaed7a0fd98091651e393feaf1faa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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