using valid_child_count

pull/1/head
Jared Cosulich 7 years ago
parent d6ae78bcad
commit 4ad2660e28

@ -36,6 +36,9 @@
= @school_category.zscore.round(1) + 3
(out of 5)
%b Valid Children:
= @school_category.valid_child_count || "N/A"
.indicator-container.py-3
= render 'school_categories/indicator', info: @school_category

@ -1,5 +1,6 @@
- aggregated_responses = question.aggregated_responses_for_school(@school)
- return if aggregated_responses.nil?
- school_question = SchoolQuestion.for(@school, question)
- valid_responses = (aggregated_responses.count.to_f / @school.available_responders_for(question).to_f) >= 0.3
.col-12.col-md-6.py-3
@ -47,3 +48,7 @@
%p.collapse{id: "raw-data#{question.id}"}
= aggregated_responses.responses.map(&:answer_index_with_reverse).join(', ')
- if school_question.present?
.clearfix
%p= "Attempts: #{school_question.attempt_count}, Responses: #{school_question.response_count}, Response Rate: #{school_question.response_rate}"

@ -455,7 +455,7 @@ namespace :data do
category.school_categories.includes(school: [:district]).find_in_batches(batch_size: 100) do |group|
group.each do |school_category|
school_questions = []
new_school_questions = []
category.questions.created_in(school_category.year).each do |question|
school = school_category.school
next if school.district.name != "Boston"
@ -465,7 +465,12 @@ namespace :data do
for_school(school).count
available_responders = school.available_responders_for(question)
school_questions << school_category.school_questions.new(
school_question = school_category.school_questions.for(school, question)
if school_question.present?
school_questions << school_question
else
school_question = school_category.school_questions.new(
school: school,
question: question,
school_category: school_category,
@ -474,9 +479,12 @@ namespace :data do
response_count: attempt_count,
response_rate: attempt_count.to_f / available_responders.to_f
)
new_school_questions << school_question
school_questions << school_question
end
end
SchoolQuestion.import school_questions
SchoolQuestion.import new_school_questions
valid_questions = school_questions.select { |sc| sc.response_rate > 0.3 }
school_category.update(
valid_child_count: valid_questions.length
@ -544,7 +552,6 @@ end
#
#
#
# loop do
# categories = Category.joins(:school_categories)
# .merge(SchoolCategory.where("valid_child_count is not null"))

Loading…
Cancel
Save