summaryrefslogtreecommitdiff
path: root/app/controllers/workouts_controller.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2017-02-12 14:35:54 -0700
committermo khan <mo@mokhan.ca>2017-02-12 14:35:54 -0700
commitebd397d8a2a041d3f70249b04aa1c842f3a61eac (patch)
tree0695f8eb347b3e146c907ad40459aa391c784c53 /app/controllers/workouts_controller.rb
parent6be51ee293ed2d7b9eb4664dd5e5cf3c0acd5149 (diff)
optimize query.
Diffstat (limited to 'app/controllers/workouts_controller.rb')
-rw-r--r--app/controllers/workouts_controller.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/controllers/workouts_controller.rb b/app/controllers/workouts_controller.rb
index 17a43db..2ab2fb9 100644
--- a/app/controllers/workouts_controller.rb
+++ b/app/controllers/workouts_controller.rb
@@ -38,11 +38,8 @@ class WorkoutsController < ApplicationController
end
def recent_workouts(exercise)
- if exercise.present?
- current_user.workouts.recent.includes(:routine).with_exercise(exercise)
- else
- current_user.workouts.recent.includes(:routine)
- end
+ workouts = current_user.workouts.recent.includes(:routine, :exercise_sets)
+ exercise ? workouts.with_exercise(exercise) : workouts
end
def find_routine(routine_id)