Fix Rubocop offenses
This commit is contained in:
@ -6,7 +6,7 @@ class AddHashedContentToFiles < ActiveRecord::Migration[4.2]
|
||||
|
||||
reversible do |direction|
|
||||
direction.up do
|
||||
CodeOcean::File.unscope(:order).all.each(&:save)
|
||||
CodeOcean::File.unscope(:order).find_each(&:save)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ class AddCauseToTestruns < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
add_column :testruns, :cause, :string
|
||||
Testrun.reset_column_information
|
||||
Testrun.all.each do |testrun|
|
||||
Testrun.find_each do |testrun|
|
||||
if testrun.submission.nil?
|
||||
say_with_time "#{testrun.id} has no submission"
|
||||
else
|
||||
|
@ -4,7 +4,7 @@ class CreateExerciseCollectionItems < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
rename_table :exercise_collections_exercises, :exercise_collection_items
|
||||
add_column :exercise_collection_items, :position, :integer, default: 0, null: false
|
||||
add_column :exercise_collection_items, :id, :primary_key
|
||||
add_column :exercise_collection_items, :id, :primary_key # rubocop:disable Rails/DangerousColumnNames
|
||||
end
|
||||
|
||||
def down
|
||||
|
@ -24,7 +24,7 @@ class DropErrors < ActiveRecord::Migration[5.2]
|
||||
submissions_controller = SubmissionsController.new
|
||||
|
||||
# Iterate only over those Errors containing a message and submission_id
|
||||
CodeOcean::Error.where.not(message: [nil, '']).where.not(submission_id: [nil, '']).each do |error|
|
||||
CodeOcean::Error.where.not(message: [nil, '']).where.not(submission_id: [nil, '']).find_each do |error|
|
||||
raw_output = error.message
|
||||
submission = Submission.find_by(id: error.submission_id)
|
||||
|
||||
|
@ -7,7 +7,7 @@ class AddNormalizedScoreAndSubmissionToUserExerciseFeedback < ActiveRecord::Migr
|
||||
|
||||
# Disable automatic timestamp modification
|
||||
ActiveRecord::Base.record_timestamps = false
|
||||
UserExerciseFeedback.all.find_each do |uef|
|
||||
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)
|
||||
|
@ -6,7 +6,7 @@ class ChangeTypeOfExposedPortsInExecutionEnvironment < ActiveRecord::Migration[6
|
||||
rename_column :execution_environments, :exposed_ports, :exposed_ports_migration
|
||||
add_column :execution_environments, :exposed_ports, :integer, array: true, default: [], nil: true
|
||||
|
||||
ExecutionEnvironment.all.each do |execution_environment|
|
||||
ExecutionEnvironment.find_each do |execution_environment|
|
||||
next if execution_environment.exposed_ports_migration.nil?
|
||||
|
||||
cleaned = execution_environment.exposed_ports_migration.scan(/\d+/)
|
||||
@ -21,7 +21,7 @@ class ChangeTypeOfExposedPortsInExecutionEnvironment < ActiveRecord::Migration[6
|
||||
rename_column :execution_environments, :exposed_ports, :exposed_ports_migration
|
||||
add_column :execution_environments, :exposed_ports, :string
|
||||
|
||||
ExecutionEnvironment.all.each do |execution_environment|
|
||||
ExecutionEnvironment.find_each do |execution_environment|
|
||||
next if execution_environment.exposed_ports_migration.empty?
|
||||
|
||||
list = execution_environment.exposed_ports_migration
|
||||
|
@ -6,13 +6,13 @@ class UnifyLtiParameters < ActiveRecord::Migration[7.0]
|
||||
dir.up do
|
||||
# We cannot add a foreign key to a table that has rows that violate the constraint.
|
||||
LtiParameter.where(external_users_id: nil)
|
||||
.or(LtiParameter.where.not(external_users_id: ExternalUser.all.select(:id)))
|
||||
.or(LtiParameter.where.not(external_users_id: ExternalUser.select(:id)))
|
||||
.or(LtiParameter.where(exercises_id: nil))
|
||||
.or(LtiParameter.where.not(exercises_id: Exercise.all.select(:id)))
|
||||
.or(LtiParameter.where.not(exercises_id: Exercise.select(:id)))
|
||||
.delete_all
|
||||
|
||||
# For each user/exercise pair, keep the most recent LtiParameter.
|
||||
LtiParameter.all.group(:external_users_id, :exercises_id).having('count(*) > 1').count.each do |ids, count|
|
||||
LtiParameter.group(:external_users_id, :exercises_id).having('count(*) > 1').count.each do |ids, count|
|
||||
LtiParameter.where(external_users_id: ids.first, exercises_id: ids.second).order(updated_at: :asc).limit(count - 1).delete_all
|
||||
end
|
||||
change_column :lti_parameters, :id, :bigint
|
||||
|
@ -4,7 +4,7 @@ class AddForeignKeysToAnomalyNotifications < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
up_only do
|
||||
# We cannot add a foreign key to a table that has rows that violate the constraint.
|
||||
AnomalyNotification.where.not(exercise_id: Exercise.all.select(:id)).delete_all
|
||||
AnomalyNotification.where.not(exercise_id: Exercise.select(:id)).delete_all
|
||||
end
|
||||
|
||||
change_column_null :anomaly_notifications, :contributor_id, false
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class ConvertReasonToJsonInAnomalyNotifications < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
AnomalyNotification.where("reason LIKE '%value:%'").each do |anomaly_notification|
|
||||
AnomalyNotification.where("reason LIKE '%value:%'").find_each do |anomaly_notification|
|
||||
reason = anomaly_notification.reason
|
||||
reason = reason.gsub('value:', '"value":')
|
||||
reason = reason.gsub(/"(\d+\.\d+)"/) {|_| Regexp.last_match(1) }
|
||||
|
Reference in New Issue
Block a user