mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
fix: ECP-124 Update grade range to be the union of grades found in the database and the enrollment of the school. "Subcategory - School & District"
# Fixed reported grades
# Runs faster
"Measure - District only"
# Should only be run per district
# Runs faster
# Fixed reported grades
"Measure - School & District"
# Reports the grades that took the survey for that school+year; not the grades that responded to the measure
# Runs faster
# Fixed reported grades
"Beyond Learning Loss"
# Runs faster
"Beyond Learning Loss - Response Rate"
# Fixed reported grades
"Survey Item - By Item"
# may be able to speed it up by getting all averages in a single request
# Fixed reported grades
"Survey Item - By Grade"
# Fixed reported grades
#may be able to speed it up by getting all averages in a single request
"Survey Entries - by Measure"
# No changes
This commit is contained in:
parent
0f457becf0
commit
058cbb0f6e
9 changed files with 55 additions and 65 deletions
|
|
@ -30,7 +30,7 @@ class ExportsController < ApplicationController
|
||||||
report = params[:report]
|
report = params[:report]
|
||||||
|
|
||||||
if ["Survey Item - By Item", "Survey Item - By Grade", "Survey Entries - by Measure"].include?(report)
|
if ["Survey Item - By Item", "Survey Item - By Grade", "Survey Entries - by Measure"].include?(report)
|
||||||
use_student_survey_items = student_survey_types[params[:student_survey_type]]
|
use_student_survey_items = student_survey_types[params[:student_survey_type]] || ::SurveyItem.student_survey_items.pluck(:id)
|
||||||
reports[report].call(schools, academic_years, use_student_survey_items)
|
reports[report].call(schools, academic_years, use_student_survey_items)
|
||||||
else
|
else
|
||||||
reports[report].call(schools, academic_years)
|
reports[report].call(schools, academic_years)
|
||||||
|
|
@ -88,8 +88,7 @@ class ExportsController < ApplicationController
|
||||||
filename: "beyond_learning_loss_response_rate_#{Date.today}.csv"
|
filename: "beyond_learning_loss_response_rate_#{Date.today}.csv"
|
||||||
},
|
},
|
||||||
"Survey Item - By Item" => lambda { |schools, academic_years, use_student_survey_items|
|
"Survey Item - By Item" => lambda { |schools, academic_years, use_student_survey_items|
|
||||||
data = Report::SurveyItemByItem.to_csv(schools:, academic_years:,
|
data = Report::SurveyItemByItem.to_csv(schools:, academic_years:, use_student_survey_items:)
|
||||||
use_student_survey_items:)
|
|
||||||
send_data data, disposition: "attachment",
|
send_data data, disposition: "attachment",
|
||||||
filename: "survey_item_by_item_#{Date.today}.csv"
|
filename: "survey_item_by_item_#{Date.today}.csv"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,18 @@ module Report
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while school = jobs.pop(true)
|
while school = jobs.pop(true)
|
||||||
academic_years.each do |academic_year|
|
academic_years.each do |academic_year|
|
||||||
scales.each do |scale|
|
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
||||||
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
next if respondents.nil?
|
||||||
next if respondents.nil?
|
|
||||||
|
|
||||||
|
begin_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
||||||
|
end_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
||||||
|
date_range = "#{begin_date} - #{end_date}"
|
||||||
|
all_grades = Respondent.grades_that_responded_to_survey(academic_year:, school:)
|
||||||
|
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||||
|
|
||||||
|
scales.each do |scale|
|
||||||
response_rate = scale.measure.subcategory.response_rate(school:, academic_year:)
|
response_rate = scale.measure.subcategory.response_rate(school:, academic_year:)
|
||||||
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
||||||
|
|
||||||
|
|
@ -37,16 +45,8 @@ module Report
|
||||||
scale.score(school:, academic_year:)
|
scale.score(school:, academic_year:)
|
||||||
end
|
end
|
||||||
|
|
||||||
begin_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
|
||||||
end_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
|
||||||
date_range = "#{begin_date} - #{end_date}"
|
|
||||||
|
|
||||||
row = [response_rate, scale, school, academic_year]
|
row = [response_rate, scale, school, academic_year]
|
||||||
|
|
||||||
all_grades = respondents.enrollment_by_grade.keys
|
|
||||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
data << [school.district.name,
|
data << [school.district.name,
|
||||||
school.name,
|
school.name,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ module Report
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
||||||
date_range = "#{begin_date} - #{end_date}"
|
date_range = "#{begin_date} - #{end_date}"
|
||||||
|
|
||||||
all_grades = respondents.enrollment_by_grade.keys
|
all_grades = Respondent.grades_that_responded_to_survey(academic_year:, school:)
|
||||||
|
|
||||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||||
|
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,25 @@ module Report
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while school = jobs.pop(true)
|
while school = jobs.pop(true)
|
||||||
academic_years.each do |academic_year|
|
academic_years.each do |academic_year|
|
||||||
|
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
||||||
|
next if respondents.nil?
|
||||||
|
|
||||||
|
begin_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
||||||
|
end_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
||||||
|
date_range = "#{begin_date} - #{end_date}"
|
||||||
|
all_grades = Respondent.grades_that_responded_to_survey(academic_year: academic_year, school: school)
|
||||||
|
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||||
|
|
||||||
measures.each do |measure|
|
measures.each do |measure|
|
||||||
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
score = measure.score(school:, academic_year:)
|
||||||
next if respondents.nil?
|
zone = measure.zone(school:, academic_year:).type.to_s.capitalize
|
||||||
|
|
||||||
response_rate = measure.subcategory.response_rate(school:, academic_year:)
|
response_rate = measure.subcategory.response_rate(school:, academic_year:)
|
||||||
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
||||||
|
|
||||||
score = measure.score(school:, academic_year:)
|
|
||||||
zone = measure.zone(school:, academic_year:).type.to_s.capitalize
|
|
||||||
|
|
||||||
begin_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
|
||||||
end_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
|
||||||
date_range = "#{begin_date} - #{end_date}"
|
|
||||||
|
|
||||||
row = [response_rate, measure, school, academic_year]
|
row = [response_rate, measure, school, academic_year]
|
||||||
|
|
||||||
all_grades = respondents.enrollment_by_grade.keys
|
|
||||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
data << [measure.name,
|
data << [measure.name,
|
||||||
measure.measure_id,
|
measure.measure_id,
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,17 @@ module Report
|
||||||
workers = pool_size.times.map do
|
workers = pool_size.times.map do
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while measure = jobs.pop(true)
|
while measure = jobs.pop(true)
|
||||||
|
all_grades = Respondent.grades_that_responded_to_survey(academic_year: academic_years, school: schools)
|
||||||
|
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||||
|
district = schools.first.district
|
||||||
|
|
||||||
academic_years.each do |academic_year|
|
academic_years.each do |academic_year|
|
||||||
respondents = Respondent.where(school: schools, academic_year:)
|
|
||||||
|
|
||||||
enrollment = respondents.map do | respondent| respondent.enrollment_by_grade.keys end.flatten.compact.uniq.sort
|
|
||||||
grades_with_responses = ::SurveyItemResponse.where(school: schools, academic_year:).where.not(grade: nil).pluck(:grade).uniq.sort
|
|
||||||
all_grades = (enrollment & grades_with_responses).sort
|
|
||||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
|
||||||
|
|
||||||
begin_date = ::SurveyItemResponse.where(school: schools,
|
begin_date = ::SurveyItemResponse.where(school: schools,
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
||||||
end_date = ::SurveyItemResponse.where(school: schools,
|
end_date = ::SurveyItemResponse.where(school: schools,
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
||||||
date_range = "#{begin_date} - #{end_date}"
|
date_range = "#{begin_date} - #{end_date}"
|
||||||
|
|
||||||
district = schools.first.district
|
|
||||||
row = [measure, district, academic_year]
|
row = [measure, district, academic_year]
|
||||||
|
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,25 @@ module Report
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while school = jobs.pop(true)
|
while school = jobs.pop(true)
|
||||||
academic_years.each do |academic_year|
|
academic_years.each do |academic_year|
|
||||||
subcategories.each do |subcategory|
|
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
||||||
respondents = Respondent.by_school_and_year(school:, academic_year:)
|
next if respondents.nil?
|
||||||
next if respondents.nil?
|
|
||||||
|
|
||||||
|
begin_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
||||||
|
end_date = ::SurveyItemResponse.where(school:,
|
||||||
|
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
||||||
|
date_range = "#{begin_date} - #{end_date}"
|
||||||
|
all_grades = Respondent.grades_that_responded_to_survey(academic_year:, school:)
|
||||||
|
grades = "#{all_grades.first}-#{all_grades.last}"
|
||||||
|
|
||||||
|
subcategories.each do |subcategory|
|
||||||
|
score = subcategory.score(school:, academic_year:)
|
||||||
|
zone = subcategory.zone(school:, academic_year:).type.to_s.capitalize
|
||||||
response_rate = subcategory.response_rate(school:, academic_year:)
|
response_rate = subcategory.response_rate(school:, academic_year:)
|
||||||
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
next unless response_rate.meets_student_threshold? || response_rate.meets_teacher_threshold?
|
||||||
|
|
||||||
score = subcategory.score(school:, academic_year:)
|
|
||||||
zone = subcategory.zone(school:, academic_year:).type.to_s.capitalize
|
|
||||||
|
|
||||||
begin_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).first&.recorded_date&.to_date
|
|
||||||
end_date = ::SurveyItemResponse.where(school:,
|
|
||||||
academic_year:).where.not(recorded_date: nil).order(:recorded_date).last&.recorded_date&.to_date
|
|
||||||
date_range = "#{begin_date} - #{end_date}"
|
|
||||||
|
|
||||||
row = [response_rate, subcategory, school, academic_year]
|
row = [response_rate, subcategory, school, academic_year]
|
||||||
|
|
||||||
all_grades = respondents.enrollment_by_grade.keys
|
|
||||||
grades = "#{all_grades.first}-#{all_grades.last}"
|
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
data << [school.district.name,
|
data << [school.district.name,
|
||||||
school.name,
|
school.name,
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,7 @@ module Report
|
||||||
# also get a map of grade->survey_id
|
# also get a map of grade->survey_id
|
||||||
sufficient_survey_items = {}
|
sufficient_survey_items = {}
|
||||||
|
|
||||||
grades = []
|
grades = Respondent.grades_that_responded_to_survey(academic_year: academic_years, school: schools)
|
||||||
schools.each do |school|
|
|
||||||
academic_years.each do |academic_year|
|
|
||||||
grades.concat(school.grades(academic_year:))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
grades = grades.uniq.reject { |grade| grade == -1 }.reject(&:nil?) # remove preschool and nil grades
|
|
||||||
|
|
||||||
grades.each do |grade|
|
grades.each do |grade|
|
||||||
sufficient_survey_items[grade] ||= Set.new
|
sufficient_survey_items[grade] ||= Set.new
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,7 @@ module Report
|
||||||
"Academic Year"
|
"Academic Year"
|
||||||
]
|
]
|
||||||
|
|
||||||
grades = []
|
grades = Respondent.grades_that_responded_to_survey(academic_year: academic_years, school: schools)
|
||||||
schools.each do |school|
|
|
||||||
academic_years.each do |academic_year|
|
|
||||||
grades.concat(school.grades(academic_year:))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
grades = grades.uniq.reject { |grade| grade == -1 }.reject(&:nil?) # remove preschool and nil grades
|
|
||||||
|
|
||||||
grades.each do |value|
|
grades.each do |value|
|
||||||
if value == 0
|
if value == 0
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,12 @@ class Respondent < ApplicationRecord
|
||||||
def total_educators
|
def total_educators
|
||||||
(total_teachers || 0) + (total_esp || 0)
|
(total_teachers || 0) + (total_esp || 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.grades_that_responded_to_survey(academic_year:, school:)
|
||||||
|
respondents = Respondent.where(school:, academic_year:)
|
||||||
|
|
||||||
|
enrollment = respondents.map { |respondent| respondent.enrollment_by_grade.keys }.flatten.compact.uniq.sort
|
||||||
|
grades_with_responses = ::SurveyItemResponse.where(school:, academic_year:).where.not(grade: nil).pluck(:grade).uniq.sort
|
||||||
|
(enrollment & grades_with_responses).sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue