Fix Rubocop offenses
This commit is contained in:
@ -21,7 +21,7 @@ module FileConversion
|
||||
# Optimize SQL queries: We are first fetching all required file types from the database.
|
||||
# Then, we store them in a hash, so that we can access them by using their file extension.
|
||||
file_types = {}
|
||||
FileType.where(file_extension: files.pluck('extension')).each do |file_type|
|
||||
FileType.where(file_extension: files.pluck('extension')).find_each do |file_type|
|
||||
file_types[file_type.file_extension] = file_type
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
||||
# GET /error_template_attributes
|
||||
# GET /error_template_attributes.json
|
||||
def index
|
||||
@error_template_attributes = ErrorTemplateAttribute.all.order('important DESC', :key,
|
||||
@error_template_attributes = ErrorTemplateAttribute.order('important DESC', :key,
|
||||
:id).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ class ErrorTemplatesController < ApplicationController
|
||||
# GET /error_templates
|
||||
# GET /error_templates.json
|
||||
def index
|
||||
@error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page], per_page: per_page_param)
|
||||
@error_templates = ErrorTemplate.order(:execution_environment_id, :name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
private :authorize!
|
||||
|
||||
def index
|
||||
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
@execution_environments = ExecutionEnvironment.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -434,7 +434,7 @@ class ExercisesController < ApplicationController
|
||||
private :not_authorized_for_exercise
|
||||
|
||||
def set_execution_environments
|
||||
@execution_environments = ExecutionEnvironment.all.order(:name)
|
||||
@execution_environments = ExecutionEnvironment.order(:name)
|
||||
end
|
||||
|
||||
private :set_execution_environments
|
||||
@ -456,7 +456,7 @@ class ExercisesController < ApplicationController
|
||||
private :set_external_user_and_authorize
|
||||
|
||||
def set_file_types
|
||||
@file_types = FileType.all.order(:name)
|
||||
@file_types = FileType.order(:name)
|
||||
end
|
||||
|
||||
private :set_file_types
|
||||
|
@ -19,7 +19,7 @@ class FileTemplatesController < ApplicationController
|
||||
# GET /file_templates
|
||||
# GET /file_templates.json
|
||||
def index
|
||||
@file_templates = FileTemplate.all.order(:file_type_id).paginate(page: params[:page], per_page: per_page_param)
|
||||
@file_templates = FileTemplate.order(:file_type_id).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ class FileTypesController < ApplicationController
|
||||
private :authorize!
|
||||
|
||||
def index
|
||||
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
@file_types = FileType.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -150,7 +150,7 @@ class InternalUsersController < ApplicationController
|
||||
@user ||= InternalUser.new # Only needed for the `create` action
|
||||
checked_study_group_memberships = @user.study_group_memberships
|
||||
checked_study_groups = checked_study_group_memberships.collect(&:study_group).sort.to_set
|
||||
unchecked_study_groups = StudyGroup.all.order(name: :asc).to_set.subtract checked_study_groups
|
||||
unchecked_study_groups = StudyGroup.order(name: :asc).to_set.subtract checked_study_groups
|
||||
@study_group_memberships = checked_study_group_memberships + unchecked_study_groups.collect do |study_group|
|
||||
StudyGroupMembership.new(user: @user, study_group:)
|
||||
end
|
||||
|
@ -377,7 +377,7 @@ class SubmissionsController < ApplicationController
|
||||
#
|
||||
# Reloading the ErrorTemplate is necessary to allow preloading the ErrorTemplateAttributes.
|
||||
# However, this results in less (and faster) SQL queries than performing manual lookups.
|
||||
ErrorTemplate.where(id: matching_error_templates).joins(:error_template_attributes).includes(:error_template_attributes).each do |template|
|
||||
ErrorTemplate.where(id: matching_error_templates).joins(:error_template_attributes).includes(:error_template_attributes).find_each do |template|
|
||||
results << StructuredError.create_from_template(template, @testrun[:output], @submission)
|
||||
end
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ class TipsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_file_types
|
||||
@file_types = FileType.all.order(:name)
|
||||
@file_types = FileType.order(:name)
|
||||
end
|
||||
private :set_file_types
|
||||
end
|
||||
|
@ -20,6 +20,6 @@ class Testrun < ApplicationRecord
|
||||
validates :status, presence: true
|
||||
|
||||
def log
|
||||
testrun_messages.output.select(:log).map(&:log).join.presence
|
||||
testrun_messages.output.pluck(:log).join.presence
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user