mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
Autoformat code with rubocop
This commit is contained in:
parent
68dde8a6ef
commit
ed7a3b8a3d
43 changed files with 112 additions and 114 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class CategoriesController < SqmApplicationController
|
||||
def show
|
||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
|
||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category:) }
|
||||
|
||||
@category = CategoryPresenter.new(category: Category.find_by_slug(params[:id]))
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ class HomeController < ApplicationController
|
|||
@districts = District.all.order(:name)
|
||||
@schools = School.all.includes([:district]).order(:name)
|
||||
|
||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
|
||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category:) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class OverviewController < SqmApplicationController
|
||||
def index
|
||||
@variance_chart_row_presenters = Measure.all.map(&method(:presenter_for_measure))
|
||||
@category_presenters = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
|
||||
@category_presenters = Category.sorted.map { |category| CategoryPresenter.new(category:) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -9,6 +9,6 @@ class OverviewController < SqmApplicationController
|
|||
def presenter_for_measure(measure)
|
||||
score = measure.score(school: @school, academic_year: @academic_year)
|
||||
|
||||
VarianceChartRowPresenter.new(measure: measure, score: score)
|
||||
VarianceChartRowPresenter.new(measure:, score:)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ module GaugeHelper
|
|||
end
|
||||
|
||||
def arc_end_point_for(radius:, percentage:)
|
||||
angle = angle_for(percentage: percentage)
|
||||
angle = angle_for(percentage:)
|
||||
|
||||
x = arc_center.x + radius * Math.cos(angle)
|
||||
y = arc_center.y + radius * Math.sin(angle)
|
||||
|
|
@ -47,8 +47,8 @@ module GaugeHelper
|
|||
end
|
||||
|
||||
def arc_end_line_destination(radius:, percentage:)
|
||||
x = arc_center.x + radius * Math.cos(angle_for(percentage: percentage))
|
||||
y = arc_center.y + radius * Math.sin(angle_for(percentage: percentage))
|
||||
x = arc_center.x + radius * Math.cos(angle_for(percentage:))
|
||||
y = arc_center.y + radius * Math.sin(angle_for(percentage:))
|
||||
Point.new(x, y)
|
||||
end
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ module GaugeHelper
|
|||
|
||||
def draw_arc(radius:, percentage:, clockwise:)
|
||||
sweep_flag = clockwise ? 1 : 0
|
||||
"A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius: radius,
|
||||
percentage: percentage))}"
|
||||
"A #{arc_radius(radius)} 0 0 #{sweep_flag} #{coordinates_for(arc_end_point_for(radius:,
|
||||
percentage:))}"
|
||||
end
|
||||
|
||||
def draw_line_to(point:)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module HeaderHelper
|
|||
end
|
||||
|
||||
def link_weight(path:)
|
||||
active?(path: path) ? 'weight-700' : 'weight-400'
|
||||
active?(path:) ? 'weight-700' : 'weight-400'
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ class AcademicYear < ActiveRecord::Base
|
|||
years = range.split('-')
|
||||
"#{years.first} – 20#{years.second}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class AdminDataPresenter < DataItemPresenter
|
||||
def initialize(measure_id:, admin_data_items:)
|
||||
super(measure_id: measure_id, has_sufficient_data: false)
|
||||
super(measure_id:, has_sufficient_data: false)
|
||||
@admin_data_items = admin_data_items
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ class CategoryPresenter
|
|||
def subcategories(academic_year:, school:)
|
||||
@category.subcategories.includes([:measures]).sort_by(&:subcategory_id).map do |subcategory|
|
||||
SubcategoryPresenter.new(
|
||||
subcategory: subcategory,
|
||||
academic_year: academic_year,
|
||||
school: school
|
||||
subcategory:,
|
||||
academic_year:,
|
||||
school:
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ class GaugePresenter
|
|||
end
|
||||
end
|
||||
|
||||
def score
|
||||
@score
|
||||
end
|
||||
attr_reader :score
|
||||
|
||||
private
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class StudentSurveyPresenter < DataItemPresenter
|
||||
def initialize(measure_id:, survey_items:, has_sufficient_data:)
|
||||
super(measure_id: measure_id, has_sufficient_data: has_sufficient_data)
|
||||
super(measure_id:, has_sufficient_data:)
|
||||
@survey_items = survey_items
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class SubcategoryPresenter
|
|||
|
||||
def teacher_response_rate
|
||||
return 'N / A' if Respondent.where(school: @school, academic_year: @academic_year).count.zero?
|
||||
|
||||
"#{@subcategory.teacher_response_rate(school: @school, academic_year: @academic_year).rate}%"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class TeacherSurveyPresenter < DataItemPresenter
|
||||
def initialize(measure_id:, survey_items:, has_sufficient_data:)
|
||||
super(measure_id: measure_id, has_sufficient_data: has_sufficient_data)
|
||||
super(measure_id:, has_sufficient_data:)
|
||||
@survey_items = survey_items
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class SurveyResponsesDataLoader
|
|||
survey_items = SurveyItem.where(survey_item_id: survey_item_ids)
|
||||
|
||||
file.lazy.each_slice(1000) do |lines|
|
||||
survey_item_responses = CSV.parse(lines.join, headers: headers).map do |row|
|
||||
survey_item_responses = CSV.parse(lines.join, headers:).map do |row|
|
||||
process_row row: row, survey_items: survey_items
|
||||
end
|
||||
|
||||
|
|
@ -36,18 +36,18 @@ class SurveyResponsesDataLoader
|
|||
return if school.nil?
|
||||
|
||||
survey_items.map do |survey_item|
|
||||
next if SurveyItemResponse.where(response_id: response_id, survey_item: survey_item).exists?
|
||||
next if SurveyItemResponse.where(response_id:, survey_item:).exists?
|
||||
|
||||
likert_score = row[survey_item.survey_item_id]
|
||||
next if likert_score.nil?
|
||||
next unless likert_score.valid_likert_score?
|
||||
|
||||
SurveyItemResponse.new(
|
||||
response_id: response_id,
|
||||
academic_year: academic_year,
|
||||
school: school,
|
||||
survey_item: survey_item,
|
||||
likert_score: likert_score
|
||||
response_id:,
|
||||
academic_year:,
|
||||
school:,
|
||||
survey_item:,
|
||||
likert_score:
|
||||
)
|
||||
end.compact
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue