diff --git a/app/helpers/statistics_helper.rb b/app/helpers/statistics_helper.rb index a43bc94c..391e7e98 100644 --- a/app/helpers/statistics_helper.rb +++ b/app/helpers/statistics_helper.rb @@ -71,15 +71,14 @@ module StatisticsHelper { key: 'submissions_per_minute', name: t('statistics.entries.exercises.submissions_per_minute'), - data: (Submission.where('created_at >= ?', DateTime.now - 1.hour).count.to_f / 60).round(2), + data: (Submission.where(created_at: DateTime.now - 1.hour..).count.to_f / 60).round(2), unit: '/min', url: statistics_graphs_path, }, { key: 'autosaves_per_minute', name: t('statistics.entries.exercises.autosaves_per_minute'), - data: (Submission.where('created_at >= ?', - DateTime.now - 1.hour).where(cause: 'autosave').count.to_f / 60).round(2), + data: (Submission.where(created_at: DateTime.now - 1.hour..).where(cause: 'autosave').count.to_f / 60).round(2), unit: '/min', }, { @@ -121,13 +120,13 @@ module StatisticsHelper key: 'active_in_last_hour', name: t('statistics.entries.users.currently_active'), data: ExternalUser.joins(:submissions) - .where(['submissions.created_at >= ?', DateTime.now - 5.minutes]) + .where(submissions: {created_at: DateTime.now - 5.minutes..}) .distinct('external_users.id').count, }, { key: 'submissions_per_minute', name: t('statistics.entries.exercises.submissions_per_minute'), - data: (Submission.where('created_at >= ?', DateTime.now - 1.hour).count.to_f / 60).round(2), + data: (Submission.where(created_at: DateTime.now - 1.hour..).count.to_f / 60).round(2), unit: '/min', axis: 'right', }, diff --git a/app/models/request_for_comment.rb b/app/models/request_for_comment.rb index 8f6d5503..38ca4c0d 100644 --- a/app/models/request_for_comment.rb +++ b/app/models/request_for_comment.rb @@ -85,7 +85,7 @@ class RequestForComment < ApplicationRecord def last_per_user(count = 5) from(row_number_user_sql, :request_for_comments) - .where('row_number <= ?', count) + .where(row_number: ..count) .group('request_for_comments.id, request_for_comments.user_id, request_for_comments.user_type, ' \ 'request_for_comments.exercise_id, request_for_comments.file_id, request_for_comments.question, ' \ 'request_for_comments.created_at, request_for_comments.updated_at, request_for_comments.solved, ' \ diff --git a/db/migrate/20201019090123_add_normalized_score_and_submission_to_user_exercise_feedback.rb b/db/migrate/20201019090123_add_normalized_score_and_submission_to_user_exercise_feedback.rb index 2fc9e8ff..04a55e3c 100644 --- a/db/migrate/20201019090123_add_normalized_score_and_submission_to_user_exercise_feedback.rb +++ b/db/migrate/20201019090123_add_normalized_score_and_submission_to_user_exercise_feedback.rb @@ -10,7 +10,7 @@ class AddNormalizedScoreAndSubmissionToUserExerciseFeedback < ActiveRecord::Migr UserExerciseFeedback.find_each do |uef| latest_submission = Submission .where(user_id: uef.user_id, user_type: uef.user_type, exercise_id: uef.exercise_id) - .where('created_at < ?', uef.updated_at) + .where(created_at: ...uef.updated_at) .order(created_at: :desc).first # In the beginning, CodeOcean allowed feedback for exercises while viewing an RfC. As a RfC