Add one-off script to list scales that lack survey responses

pull/1/head
Nelson Jovel 4 years ago
parent 9c954f97ec
commit 87e6a998b7

@ -1,6 +1,7 @@
class Scale < ApplicationRecord class Scale < ApplicationRecord
belongs_to :measure belongs_to :measure
has_many :survey_items has_many :survey_items
has_many :survey_item_responses, through: :survey_items
has_many :admin_data_items has_many :admin_data_items
def score(school:, academic_year:) def score(school:, academic_year:)

@ -52,4 +52,16 @@ namespace :one_off do
SurveyResponsesDataLoader.load_data filepath: filepath SurveyResponsesDataLoader.load_data filepath: filepath
puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses" puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses"
end end
desc 'list scales that have no survey responses'
task list_scales_that_lack_survey_responses: :environment do
output = AcademicYear.all.map do |academic_year|
Scale.all.map do |scale|
[academic_year.range, scale.scale_id, scale.survey_item_responses.where(academic_year:).count]
end
end
output = output.map { |year| year.reject { |scale| scale[2] > 0 || scale[1].starts_with?('a-') } }
pp output
end
end end

Loading…
Cancel
Save