From 8cfb9d22c175430418e2edd69e37bcef0ec87acc Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 21 Sep 2023 11:26:05 +0200 Subject: [PATCH] Use Ruby interval for where query --- app/controllers/exercises_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index b2052429..37a46b92 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -320,8 +320,7 @@ class ExercisesController < ApplicationController end user_solved_exercise = @exercise.solved_by?(current_contributor) - count_interventions_today = UserExerciseIntervention.where(user: current_user).where('created_at >= ?', - Time.zone.now.beginning_of_day).count + count_interventions_today = UserExerciseIntervention.where(user: current_user).where(created_at: Time.zone.now.beginning_of_day..).count user_got_intervention_in_exercise = UserExerciseIntervention.where(user: current_user, exercise: @exercise).size >= max_intervention_count_per_exercise (user_got_enough_interventions = count_interventions_today >= max_intervention_count_per_day) || user_got_intervention_in_exercise