From 9c556ec8a37e06dc4d4aa7f482a04fed0f5ff5f5 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Fri, 8 Mar 2019 10:25:09 -0500 Subject: [PATCH] sort school categories by root category for Boston --- app/views/schools/show.html.haml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/schools/show.html.haml b/app/views/schools/show.html.haml index 207b66e0..642e1e93 100644 --- a/app/views/schools/show.html.haml +++ b/app/views/schools/show.html.haml @@ -8,8 +8,16 @@ %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 } + - grouped = @school_categories.inject({}) do |hash, item| + - all = hash[item.category.path.first] || [] + - all << item + - hash[item.category.path.first] = all + - hash + - grouped.each do |root_category, group| + .row.pt-3.mt-3 + %h3= root_category.name + .row + = render group.sort { |a, b| a.category.name <=> b.category.name } - else .row = render @school_categories.sort { |a, b| a.root_index <=> b.root_index }