diff --git a/app/presenters/analyze/graph/all_data.rb b/app/presenters/analyze/graph/all_data.rb index 0ba5f3db..80d9652b 100644 --- a/app/presenters/analyze/graph/all_data.rb +++ b/app/presenters/analyze/graph/all_data.rb @@ -26,11 +26,15 @@ module Analyze end def source - Analyze::Source::AllData.new(slices: [slice]) + Analyze::Source::AllData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::AllData.new + Analyze::Slice::AllData.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: nil, slug: nil, graph: nil) end def show_irrelevancy_message?(measure:) diff --git a/app/presenters/analyze/graph/all_parent.rb b/app/presenters/analyze/graph/all_parent.rb index 48ba5924..c051f624 100644 --- a/app/presenters/analyze/graph/all_parent.rb +++ b/app/presenters/analyze/graph/all_parent.rb @@ -16,11 +16,15 @@ module Analyze end def source - Analyze::Source::AllData.new(slices: [slice]) + Analyze::Source::AllData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::AllData.new + Analyze::Slice::AllData.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: nil, slug: nil, graph: nil) end end end diff --git a/app/presenters/analyze/graph/students_and_teachers.rb b/app/presenters/analyze/graph/students_and_teachers.rb index d1fb5ccc..d5902a77 100644 --- a/app/presenters/analyze/graph/students_and_teachers.rb +++ b/app/presenters/analyze/graph/students_and_teachers.rb @@ -17,11 +17,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsAndTeachers.new + Analyze::Slice::StudentsAndTeachers.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: nil, slug: nil, graph: nil) end end end diff --git a/app/presenters/analyze/graph/students_and_teachers_and_parents.rb b/app/presenters/analyze/graph/students_and_teachers_and_parents.rb new file mode 100644 index 00000000..a41de9bc --- /dev/null +++ b/app/presenters/analyze/graph/students_and_teachers_and_parents.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Analyze + module Graph + class StudentsAndTeachersAndParents + include Analyze::Graph::Column + def to_s + "Students & Teachers & Parents" + end + + def slug + "students-and-teachers-and-parents" + end + + def columns + [AllStudent.new, AllTeacher.new, AllSurveyData.new] + end + + def source + Analyze::Source::SurveyData.new(slices: [slice], graph: self) + end + + def slice + Analyze::Slice::StudentsAndTeachersAndParents.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: nil, slug: nil, graph: nil) + end + end + end +end diff --git a/app/presenters/analyze/graph/students_by_ell.rb b/app/presenters/analyze/graph/students_by_ell.rb index 5ef3eee2..75615486 100644 --- a/app/presenters/analyze/graph/students_by_ell.rb +++ b/app/presenters/analyze/graph/students_by_ell.rb @@ -28,11 +28,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "ELL", slug: "ell", graph: self) end end end diff --git a/app/presenters/analyze/graph/students_by_gender.rb b/app/presenters/analyze/graph/students_by_gender.rb index 333098c5..093e1075 100644 --- a/app/presenters/analyze/graph/students_by_gender.rb +++ b/app/presenters/analyze/graph/students_by_gender.rb @@ -28,11 +28,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "Gender", slug: "gender", graph: self) end end end diff --git a/app/presenters/analyze/graph/students_by_grade.rb b/app/presenters/analyze/graph/students_by_grade.rb index a28451e4..604e715e 100644 --- a/app/presenters/analyze/graph/students_by_grade.rb +++ b/app/presenters/analyze/graph/students_by_grade.rb @@ -27,11 +27,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "Grade", slug: "grade", graph: self) end end end diff --git a/app/presenters/analyze/graph/students_by_income.rb b/app/presenters/analyze/graph/students_by_income.rb index 1f1b256d..c00c2599 100644 --- a/app/presenters/analyze/graph/students_by_income.rb +++ b/app/presenters/analyze/graph/students_by_income.rb @@ -27,11 +27,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "Income", slug: "income", graph: self) end end end diff --git a/app/presenters/analyze/graph/students_by_race.rb b/app/presenters/analyze/graph/students_by_race.rb index 740d4c09..8968abde 100644 --- a/app/presenters/analyze/graph/students_by_race.rb +++ b/app/presenters/analyze/graph/students_by_race.rb @@ -27,11 +27,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: [slice], graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "Race", slug: "race", graph: self) end end end diff --git a/app/presenters/analyze/graph/students_by_sped.rb b/app/presenters/analyze/graph/students_by_sped.rb index d6afe386..7e80933d 100644 --- a/app/presenters/analyze/graph/students_by_sped.rb +++ b/app/presenters/analyze/graph/students_by_sped.rb @@ -27,11 +27,15 @@ module Analyze end def source - Analyze::Source::SurveyData.new(slices: nil) + Analyze::Source::SurveyData.new(slices: nil, graph: self) end def slice - Analyze::Slice::StudentsByGroup.new + Analyze::Slice::StudentsByGroup.new(graph: self) + end + + def group + Analyze::Group::Base.new(name: "Special Education", slug: "sped", graph: self) end end end diff --git a/app/presenters/analyze/group/base.rb b/app/presenters/analyze/group/base.rb new file mode 100644 index 00000000..37a9ff86 --- /dev/null +++ b/app/presenters/analyze/group/base.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Analyze + module Group + class Base + attr_reader :name, :slug, :graph + + def initialize(name:, slug:, graph:) + @name = name + @slug = slug + @graph = graph + end + end + end +end diff --git a/app/presenters/analyze/group/ell.rb b/app/presenters/analyze/group/ell.rb deleted file mode 100644 index 628ef0ca..00000000 --- a/app/presenters/analyze/group/ell.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Ell - def name - "ELL" - end - - def slug - "ell" - end - - def graph - Analyze::Graph::StudentsByEll.new(ells: nil) - end - end - end -end diff --git a/app/presenters/analyze/group/gender.rb b/app/presenters/analyze/group/gender.rb deleted file mode 100644 index 9810d893..00000000 --- a/app/presenters/analyze/group/gender.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Gender - def name - "Gender" - end - - def slug - "gender" - end - - def graph - Analyze::Graph::StudentsByGender.new(genders: nil) - end - end - end -end diff --git a/app/presenters/analyze/group/grade.rb b/app/presenters/analyze/group/grade.rb deleted file mode 100644 index 67149012..00000000 --- a/app/presenters/analyze/group/grade.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Grade - def name - "Grade" - end - - def slug - "grade" - end - - def graph - Analyze::Graph::StudentsByGrade.new(grades: nil) - end - end - end -end diff --git a/app/presenters/analyze/group/income.rb b/app/presenters/analyze/group/income.rb deleted file mode 100644 index 74ba80c0..00000000 --- a/app/presenters/analyze/group/income.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Income - def name - "Income" - end - - def slug - "income" - end - - def graph - Analyze::Graph::StudentsByIncome.new(incomes: nil) - end - end - end -end diff --git a/app/presenters/analyze/group/race.rb b/app/presenters/analyze/group/race.rb deleted file mode 100644 index fec01545..00000000 --- a/app/presenters/analyze/group/race.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Race - def name - "Race" - end - - def slug - "race" - end - - def graph - Analyze::Graph::StudentsByRace.new(races: nil) - end - end - end -end diff --git a/app/presenters/analyze/group/sped.rb b/app/presenters/analyze/group/sped.rb deleted file mode 100644 index cfe1e76e..00000000 --- a/app/presenters/analyze/group/sped.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Analyze - module Group - class Sped - def name - "Special Education" - end - - def slug - "sped" - end - - def graph - Analyze::Graph::StudentsBySped.new(speds: nil) - end - end - end -end diff --git a/app/presenters/analyze/presenter.rb b/app/presenters/analyze/presenter.rb index 550a6c84..d3dde077 100644 --- a/app/presenters/analyze/presenter.rb +++ b/app/presenters/analyze/presenter.rb @@ -96,8 +96,10 @@ module Analyze end def groups - @groups = [Analyze::Group::Ell.new, Analyze::Group::Gender.new, Analyze::Group::Grade.new, Analyze::Group::Income.new, - Analyze::Group::Race.new, Analyze::Group::Sped.new] + @groups = graphs.map(&:group) + .reject { |group| group.name.nil? } + .sort_by { |group| group.name } + .uniq end def group @@ -111,7 +113,13 @@ module Analyze end def slices - graphs.map { |graph| graph.slice }.uniq + @slices ||= begin + hash = {} + graphs.map(&:slice).each do |slice| + hash[slice.slug] = slice + end + hash.values + end end def source @@ -121,7 +129,7 @@ module Analyze def show_secondary_graph?(measure:) return false unless measure.includes_parent_survey_items? - graph.slug == "all-data" + ["all-data", "students-and-teachers-and-parents"].include?(graph.slug) end def columns_for_measure(measure:) @@ -133,33 +141,25 @@ module Analyze end def sources - all_data_slice = Analyze::Slice::AllData.new - all_data_slice.graph = Analyze::Graph::AllData.new - all_data_slices = [all_data_slice] - - all_data_source = Analyze::Source::AllData.new(slices: all_data_slices) - all_data_source.graph = Analyze::Graph::AllData.new - - students_and_teachers = Analyze::Slice::StudentsAndTeachers.new - students_by_group = Analyze::Slice::StudentsByGroup.new - students_by_group.graph = Analyze::Graph::StudentsByEll.new(ells: selected_ells) - - survey_data_slices = [students_and_teachers, students_by_group] - survey_data_source = Analyze::Source::SurveyData.new(slices: survey_data_slices) - survey_data_source.graph = Analyze::Graph::StudentsAndTeachers.new - - @sources = [all_data_source, survey_data_source] + @sources ||= begin + hash = {} + graphs.map(&:source).each do |source| + hash[source.slug] = source + end + hash.values + end end def graphs @graphs ||= [Analyze::Graph::AllData.new, Analyze::Graph::StudentsAndTeachers.new, + Analyze::Graph::StudentsAndTeachersAndParents.new, Analyze::Graph::StudentsByRace.new(races: selected_races), Analyze::Graph::StudentsByGrade.new(grades: selected_grades), Analyze::Graph::StudentsByGender.new(genders: selected_genders), Analyze::Graph::StudentsByIncome.new(incomes: selected_incomes), - Analyze::Graph::StudentsByEll.new(ells: selected_ells), - Analyze::Graph::StudentsBySped.new(speds: selected_speds)] + Analyze::Graph::StudentsBySped.new(speds: selected_speds), + Analyze::Graph::StudentsByEll.new(ells: selected_ells)] end def graph diff --git a/app/presenters/analyze/slice/all_data.rb b/app/presenters/analyze/slice/all_data.rb index 326af4b2..90f921fc 100644 --- a/app/presenters/analyze/slice/all_data.rb +++ b/app/presenters/analyze/slice/all_data.rb @@ -1,14 +1,8 @@ module Analyze module Slice - class AllData - attr_accessor :graph - - def to_s - "All Data" - end - - def slug - "all-data" + class AllData < Base + def initialize(graph:, label: "All Data", slug: "all-data") + super(label:, slug:, graph:) end end end diff --git a/app/presenters/analyze/slice/base.rb b/app/presenters/analyze/slice/base.rb new file mode 100644 index 00000000..cb3e42a1 --- /dev/null +++ b/app/presenters/analyze/slice/base.rb @@ -0,0 +1,17 @@ +module Analyze + module Slice + class Base + attr_reader :graph, :label, :slug + + def initialize(label:, slug:, graph:) + @label = label + @slug = slug + @graph = graph + end + + def to_s + label + end + end + end +end diff --git a/app/presenters/analyze/slice/students_and_teachers.rb b/app/presenters/analyze/slice/students_and_teachers.rb index e14ef29e..e4c5489c 100644 --- a/app/presenters/analyze/slice/students_and_teachers.rb +++ b/app/presenters/analyze/slice/students_and_teachers.rb @@ -1,16 +1,8 @@ module Analyze module Slice - class StudentsAndTeachers - def to_s - "Students & Teachers" - end - - def slug - "students-and-teachers" - end - - def graph - Analyze::Graph::StudentsAndTeachers.new + class StudentsAndTeachers < Base + def initialize(graph:, label: "Students & Teachers", slug: "students-and-teachers") + super(label:, slug:, graph:) end end end diff --git a/app/presenters/analyze/slice/students_and_teachers_and_parents.rb b/app/presenters/analyze/slice/students_and_teachers_and_parents.rb new file mode 100644 index 00000000..08f66efd --- /dev/null +++ b/app/presenters/analyze/slice/students_and_teachers_and_parents.rb @@ -0,0 +1,9 @@ +module Analyze + module Slice + class StudentsAndTeachersAndParents < Base + def initialize(graph:, label: "Students & Teachers & Parents", slug: "students-and-teachers-and-pareents") + super(label:, slug:, graph:) + end + end + end +end diff --git a/app/presenters/analyze/slice/students_by_group.rb b/app/presenters/analyze/slice/students_by_group.rb index ae91d060..f015e5f5 100644 --- a/app/presenters/analyze/slice/students_by_group.rb +++ b/app/presenters/analyze/slice/students_by_group.rb @@ -1,14 +1,8 @@ module Analyze module Slice - class StudentsByGroup - attr_accessor :graph - - def to_s - "Students by Group" - end - - def slug - "students-by-group" + class StudentsByGroup < Base + def initialize(graph:, label: "Students by Group", slug: "students-by-group") + super(label:, slug:, graph:) end end end diff --git a/app/presenters/analyze/source/all_data.rb b/app/presenters/analyze/source/all_data.rb index 181a8947..6870645c 100644 --- a/app/presenters/analyze/source/all_data.rb +++ b/app/presenters/analyze/source/all_data.rb @@ -1,13 +1,11 @@ module Analyze module Source class AllData - attr_reader :slices - attr_accessor :graph + attr_reader :slices, :graph - include Analyze::Slice - - def initialize(slices:) + def initialize(slices:, graph:) @slices = slices + @graph = graph end def to_s diff --git a/app/presenters/analyze/source/survey_data.rb b/app/presenters/analyze/source/survey_data.rb index 8510999f..3d7bd3af 100644 --- a/app/presenters/analyze/source/survey_data.rb +++ b/app/presenters/analyze/source/survey_data.rb @@ -1,13 +1,11 @@ module Analyze module Source class SurveyData - attr_reader :slices - attr_accessor :graph + attr_reader :slices, :graph - include Analyze::Slice - - def initialize(slices:) + def initialize(slices:, graph:) @slices = slices + @graph = graph end def to_s diff --git a/app/views/analyze/_data_filters.html.erb b/app/views/analyze/_data_filters.html.erb index 01466b54..da0dfd0e 100644 --- a/app/views/analyze/_data_filters.html.erb +++ b/app/views/analyze/_data_filters.html.erb @@ -26,36 +26,38 @@ <% end %> +<% if source.slug != "all-data" %> + <%= form_with(url: district_school_analyze_index_path, + method: :get, + data: { + turbo_frame: "results", + turbo_action: "advance", + controller: "analyze", + action: "input->analyze#submit" + }) do |f| %> + + <% params.reject{|key,_| key == "graph"}.each do |key, value| %> + + <% end %> -<%= form_with(url: district_school_analyze_index_path, - method: :get, - data: { - turbo_frame: "results", - turbo_action: "advance", - controller: "analyze", - action: "input->analyze#submit" - }) do |f| %> - - <% params.reject{|key,_| key == "graph"}.each do |key, value| %> - - <% end %> - - <% source.slices.each do | slice | %> -