diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index c72c66da..5c369723 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -7,16 +7,22 @@ class SchoolsController < ApplicationController # GET /schools/1 # GET /schools/1.json def show - district = @school.district - authenticate(district.name.downcase, "#{district.name.downcase}!") - - @school_categories = @school.school_categories.for_parent_category(@school, nil).valid.sort + @district = @school.district + authenticate(@district.name.downcase, "#{@district.name.downcase}!") + + if @district.name == "Boston" + @categories = Category.joins(:questions) + @school_categories = SchoolCategory.where(school: @school).where(category: @categories).to_a + else + @categories = Category.root + @school_categories = @school.school_categories.for_parent_category(@school, nil).valid.sort + end @years = @school_categories.map(&:year).map(&:to_i).sort.uniq @year = (params[:year] || @years.last || "2018").to_i @years.delete(@year) - missing_categories = Category.root - @school_categories.map(&:category) + missing_categories = @categories - @school_categories.map(&:category) missing_categories.each do |category| @school_categories << category.school_categories.new(school: @school, year: @year) end diff --git a/app/models/school_category.rb b/app/models/school_category.rb index db8534b7..aad57f83 100644 --- a/app/models/school_category.rb +++ b/app/models/school_category.rb @@ -83,6 +83,8 @@ class SchoolCategory < ApplicationRecord end def sync_aggregated_responses + # This doesn't seem to be taking into account valid_child_count or Boston's "Community and Wellbeing" category which should be suppressed if the "Health" category is the only child category visible. + return if ENV['BULK_PROCESS'] update_attributes(chained_aggregated_responses) return if response_count == 0 && zscore.nil? diff --git a/app/views/schools/show.html.haml b/app/views/schools/show.html.haml index 1dd0674c..207b66e0 100644 --- a/app/views/schools/show.html.haml +++ b/app/views/schools/show.html.haml @@ -7,6 +7,9 @@ .col-12.text-center %h3 Insufficient Responses %p No data is displayed for this school because of insufficient responses. +- elsif @district.name == "Boston" + .row + = render @school_categories.sort { |a, b| a.category.name <=> b.category.name } - else .row = render @school_categories.sort { |a, b| a.root_index <=> b.root_index }