mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Add one-off script to list scales that lack survey responses
This commit is contained in:
parent
9c954f97ec
commit
87e6a998b7
2 changed files with 13 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
class Scale < ApplicationRecord
|
||||
belongs_to :measure
|
||||
has_many :survey_items
|
||||
has_many :survey_item_responses, through: :survey_items
|
||||
has_many :admin_data_items
|
||||
|
||||
def score(school:, academic_year:)
|
||||
|
|
|
|||
|
|
@ -52,4 +52,16 @@ namespace :one_off do
|
|||
SurveyResponsesDataLoader.load_data filepath: filepath
|
||||
puts "=====================> Completed loading #{SurveyItemResponse.count} survey responses"
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue