chore: get overview page to display without errors

This commit is contained in:
Nelson Jovel 2024-01-17 14:47:26 -08:00
parent 64b4d599c7
commit 650a91ca62
5 changed files with 16 additions and 20 deletions

View file

@ -24,17 +24,15 @@ module Dashboard
end
def student_survey_items_with_sufficient_responses(school:, academic_year:)
# @student_survey_items_with_sufficient_responses ||= SurveyItem.where(id: SurveyItem.joins("inner join dashboard_survey_item_responses on dashboard_survey_item_responses.survey_item_id = dashboard_survey_items.id")
# .student_survey_items
# .where("dashboard_survey_item_responses.school": school,
# "dashboard_survey_item_responses.academic_year": academic_year,
# "dashboard_survey_item_responses.survey_item_id": survey_items.student_survey_items,
# "dashboard_survey_item_responses.grade": school.grades(academic_year:))
# .group("survey_items.id")
# .having("count(*) >= 10")
# .count.keys)
@student_survey_items_with_sufficient_responses ||= student_survey_items
@student_survey_items_with_sufficient_responses ||= SurveyItem.where(id: SurveyItem.joins("inner join dashboard_survey_item_responses on dashboard_survey_item_responses.dashboard_survey_item_id = dashboard_survey_items.id")
.student_survey_items
.where("dashboard_survey_item_responses.dashboard_school_id": school.id,
"dashboard_survey_item_responses.dashboard_academic_year_id": academic_year.id,
"dashboard_survey_item_responses.dashboard_survey_item_id": survey_items.student_survey_items,
"dashboard_survey_item_responses.grade": school.grades(academic_year:))
.group("dashboard_survey_items.id")
.having("count(*) >= 10")
.count.keys)
end
def teacher_scales

View file

@ -1,9 +1,8 @@
module Dashboard
class Score < ApplicationRecord
belongs_to :dashboard_measure
belongs_to :school
belongs_to :dashboard_academic_year
belongs_to :dashboard_race
belongs_to :measure, class_name: "Measure", foreign_key: :dashboard_measure_id
belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id
NIL_SCORE = Score.new(average: nil, meets_teacher_threshold: false, meets_student_threshold: false,
meets_admin_data_threshold: false)

View file

@ -5,7 +5,7 @@ module Dashboard
belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id
belongs_to :survey_item, class_name: "SurveyItem", foreign_key: :dashboard_survey_item_id
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id
belongs_to :dashboard_student, optional: true
belongs_to :dashboard_gender, optional: true
belongs_to :dashboard_income, optional: true