new boston view

pull/1/head
Jared Cosulich 7 years ago
parent f4542c7a20
commit 07d3175761

@ -7,16 +7,22 @@ class SchoolsController < ApplicationController
# GET /schools/1 # GET /schools/1
# GET /schools/1.json # GET /schools/1.json
def show def show
district = @school.district @district = @school.district
authenticate(district.name.downcase, "#{district.name.downcase}!") authenticate(@district.name.downcase, "#{@district.name.downcase}!")
@school_categories = @school.school_categories.for_parent_category(@school, nil).valid.sort 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 @years = @school_categories.map(&:year).map(&:to_i).sort.uniq
@year = (params[:year] || @years.last || "2018").to_i @year = (params[:year] || @years.last || "2018").to_i
@years.delete(@year) @years.delete(@year)
missing_categories = Category.root - @school_categories.map(&:category) missing_categories = @categories - @school_categories.map(&:category)
missing_categories.each do |category| missing_categories.each do |category|
@school_categories << category.school_categories.new(school: @school, year: @year) @school_categories << category.school_categories.new(school: @school, year: @year)
end end

@ -83,6 +83,8 @@ class SchoolCategory < ApplicationRecord
end end
def sync_aggregated_responses 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'] return if ENV['BULK_PROCESS']
update_attributes(chained_aggregated_responses) update_attributes(chained_aggregated_responses)
return if response_count == 0 && zscore.nil? return if response_count == 0 && zscore.nil?

@ -7,6 +7,9 @@
.col-12.text-center .col-12.text-center
%h3 Insufficient Responses %h3 Insufficient Responses
%p No data is displayed for this school because of 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 - else
.row .row
= render @school_categories.sort { |a, b| a.root_index <=> b.root_index } = render @school_categories.sort { |a, b| a.root_index <=> b.root_index }

Loading…
Cancel
Save