Autoformat code with rubocop

This commit is contained in:
Nelson Jovel 2022-03-04 15:29:54 +01:00
parent 68dde8a6ef
commit ed7a3b8a3d
43 changed files with 112 additions and 114 deletions

View file

@ -14,5 +14,4 @@ class AcademicYear < ActiveRecord::Base
years = range.split('-')
"#{years.first} 20#{years.second}"
end
end

View file

@ -2,7 +2,7 @@ class Category < ActiveRecord::Base
include FriendlyId
friendly_id :name, use: [:slugged]
scope :sorted, -> { order(:sort_index)}
scope :sorted, -> { order(:sort_index) }
has_many :subcategories
has_many :measures, through: :subcategories

View file

@ -58,9 +58,9 @@ module Legacy
def save_response(answer_index: nil, twilio_details: nil, responded_at: Time.new)
update(
answer_index: answer_index,
twilio_details: twilio_details,
responded_at: responded_at
answer_index:,
twilio_details:,
responded_at:
)
recipient_schedule.update(next_attempt_at: Time.new) if recipient_schedule.queued_question_ids.present?

View file

@ -22,7 +22,7 @@ module Legacy
validates :option4, presence: true
validates :option5, presence: true
scope :for_category, ->(category) { where(category: category) }
scope :for_category, ->(category) { where(category:) }
scope :created_in, ->(year) { where("extract(year from #{table_name}.created_at) = ?", year) }
enum target_group: %i[unknown for_students for_teachers for_parents]

View file

@ -9,7 +9,7 @@ module Legacy
after_initialize :set_question_id_array
def questions
question_id_array.collect { |id| Question.where(id: id).first }.compact
question_id_array.collect { |id| Question.where(id:).first }.compact
end
private

View file

@ -12,7 +12,7 @@ module Legacy
validates :name, presence: true
scope :for_school, ->(school) { where(school: school) }
scope :for_school, ->(school) { where(school:) }
scope :created_in, ->(year) { where('extract(year from recipients.created_at) = ?', year) }
before_destroy :sync_lists

View file

@ -14,7 +14,7 @@ module Legacy
after_save :sync_recipient_schedules
def recipients
recipient_id_array.collect { |id| school.recipients.where(id: id).first }
recipient_id_array.collect { |id| school.recipients.where(id:).first }
end
private

View file

@ -51,7 +51,7 @@ module Legacy
return if recipient.opted_out?
return if question.nil?
return attempt_question(question: question) unless question.for_recipient_students?
return attempt_question(question:) unless question.for_recipient_students?
missing_students = []
recipient_attempts = attempts.for_recipient(recipient).for_question(question)
@ -60,9 +60,9 @@ module Legacy
end
attempt = recipient.attempts.create(
schedule: schedule,
schedule:,
recipient_schedule: self,
question: question,
question:,
student: missing_students.first
)
@ -101,12 +101,12 @@ module Legacy
return if question.nil? && unanswered_attempt.nil?
if unanswered_attempt.nil?
return attempt_question_for_recipient_students(question: question) if question.for_recipient_students?
return attempt_question_for_recipient_students(question:) if question.for_recipient_students?
attempt = recipient.attempts.create(
schedule: schedule,
schedule:,
recipient_schedule: self,
question: question
question:
)
end
@ -159,9 +159,9 @@ module Legacy
end
schedule.recipient_schedules.create(
recipient_id: recipient_id,
recipient_id:,
upcoming_question_ids: question_ids.join(','),
next_attempt_at: next_attempt_at
next_attempt_at:
)
end
end

View file

@ -9,7 +9,7 @@ module Legacy
validates_associated :school_category
scope :for, ->(school, question) { where(school_id: school.id, question_id: question.id) }
scope :in, ->(year) { where(year: year) }
scope :in, ->(year) { where(year:) }
def sync_attempts
attempt_data = Attempt