summaryrefslogtreecommitdiff
path: root/app/controllers/workouts_controller.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2017-02-18 09:19:04 -0700
committermo khan <mo@mokhan.ca>2017-02-18 09:19:04 -0700
commite113ec03ea4eee8a1bce53348c8fa5673a0ce36d (patch)
tree2501414138358f6a1aa7c76fa6b3b60a93019d51 /app/controllers/workouts_controller.rb
parent46eecdf8dc0dc8f38a6cab499fc47962a86375b7 (diff)
fix the range selection.
Diffstat (limited to 'app/controllers/workouts_controller.rb')
-rw-r--r--app/controllers/workouts_controller.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/controllers/workouts_controller.rb b/app/controllers/workouts_controller.rb
index 76842d4..74bf26b 100644
--- a/app/controllers/workouts_controller.rb
+++ b/app/controllers/workouts_controller.rb
@@ -3,7 +3,7 @@ class WorkoutsController < ApplicationController
def index
@ranges = [5.years, 1.year, 6.months, 3.months, 1.month, 2.weeks, 1.week].reverse
- @exercise = Exercise.find_by(name: params[:exercise])
+ @exercise = Exercise.find_by(id: params[:exercise])
@primary_exercises = Exercise.primary.order_by_name.to_a
@workouts = recent_workouts(@exercise)
end
@@ -41,7 +41,8 @@ class WorkoutsController < ApplicationController
)
end
- def recent_workouts(exercise, since = (params[:since] || 30.days.to_i).to_i.seconds.ago)
+ def recent_workouts(exercise, since = (params[:since] || 7.days.to_i).to_i.seconds.ago)
+ @since = since.beginning_of_day
workouts = current_user.workouts.since(since).recent.includes(:routine)
exercise ? workouts.with_exercise(exercise) : workouts
end