From 7ddada50503e4b321b80d49b99539d2f23eb9070 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Mon, 19 Dec 2022 20:09:09 -0800 Subject: [PATCH] Update empty dataset indicators --- app/helpers/analyze_helper.rb | 10 ++++++++++ app/views/analyze/_school_years.html.erb | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/helpers/analyze_helper.rb b/app/helpers/analyze_helper.rb index ddcdef1b..a4db09d0 100644 --- a/app/helpers/analyze_helper.rb +++ b/app/helpers/analyze_helper.rb @@ -49,6 +49,16 @@ module AnalyzeHelper @empty_dataset[[school, academic_year]] end + def empty_survey_dataset?(measures:, school:, academic_year:) + @empty_survey_dataset ||= Hash.new do |memo, (school, academic_year)| + memo[[school, academic_year]] = measures.none? do |measure| + response_rate = measure.subcategory.response_rate(school:, academic_year:) + response_rate.meets_student_threshold || response_rate.meets_teacher_threshold + end + end + @empty_survey_dataset[[school, academic_year]] + end + def base_url analyze_subcategory_link(district: @district, school: @school, academic_year: @academic_year, category: @category, subcategory: @subcategory) diff --git a/app/views/analyze/_school_years.html.erb b/app/views/analyze/_school_years.html.erb index 13fd5f2a..fd18cb78 100644 --- a/app/views/analyze/_school_years.html.erb +++ b/app/views/analyze/_school_years.html.erb @@ -8,12 +8,23 @@ value="<%= analyze_subcategory_link(district: district, school: school, academic_year: academic_year, category: category, subcategory: subcategory) %>" <%= selected_academic_years.include?(year) ? "checked" : "" %> data-action="click->analyze#refresh" - <%= empty_dataset?(measures: measures, school: school, academic_year: year) ? "disabled" : "" %> - <%# <%= @graph.value == 'students-by-group' && year.range != @available_academic_years.last.range ? "disabled" : "" %1> %>> - + <% empty_dataset = empty_dataset?(measures: measures, school: school, academic_year: year) %> + <% empty_survey_dataset = empty_survey_dataset?(measures: measures, school: school, academic_year: year) %> + <% if @graph.slug == 'all-data' %> + <%= empty_dataset ? "disabled" : "" %> + <% else %> + <%= empty_survey_dataset ? "disabled" : "" %> + <% end %> + >
- <% if empty_dataset?(measures: measures, school: school, academic_year: year) %> + <% if @graph.slug == 'all-data' && empty_dataset %> + + + <% end %> + <% if @graph.slug != 'all-data' && empty_survey_dataset %>