Skip to content

Instantly share code, notes, and snippets.

@Gazer
Created November 23, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gazer/b73eaed7a0fd98091651e393feaf1faa to your computer and use it in GitHub Desktop.
Save Gazer/b73eaed7a0fd98091651e393feaf1faa to your computer and use it in GitHub Desktop.
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