mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-11 00:10:35 -07:00
Prefer using over uniq so the filtering happens in sql
This commit is contained in:
parent
30eae881f3
commit
043f6de8e7
1 changed files with 1 additions and 3 deletions
|
|
@ -88,11 +88,9 @@ class RaceScoreLoader
|
|||
|
||||
def self.sufficient_responses(school:, academic_year:, race:)
|
||||
@sufficient_responses ||= Hash.new do |memo, (school, academic_year, race)|
|
||||
# number_of_students_for_a_racial_group = SurveyItemResponse.where(school:, academic_year:,
|
||||
# student: students).map(&:student).uniq.count
|
||||
number_of_students_for_a_racial_group = SurveyItemResponse.joins('JOIN student_races on survey_item_responses.student_id = student_races.student_id JOIN students on students.id = student_races.student_id').where(
|
||||
school:, academic_year:
|
||||
).where("student_races.race_id": race.id).pluck(:student_id).uniq.count
|
||||
).where("student_races.race_id": race.id).distinct.pluck(:student_id).count
|
||||
memo[[school, academic_year, race]] = number_of_students_for_a_racial_group >= 10
|
||||
end
|
||||
@sufficient_responses[[school, academic_year, race]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue