From ec24ccf1a76206f9762d0cc9eb95a91a489fab2c Mon Sep 17 00:00:00 2001 From: maebeale Date: Thu, 18 Jun 2026 14:53:04 -0400 Subject: [PATCH 1/2] Show primary/additional age groups as chips on recipients page The scholarship recipients page still rendered age ranges as a flat comma-separated string while sectors already showed the primary/additional chip treatment. Now that people carry a primary age-group distinction (categorizable_items.is_primary), render the same starred-chip format so the "Ages" strip reads in parallel with "Serves", falling back to the form answer / profile text only when no age groups are tagged. Eager-load categorizable_items on scholarship_applicants so the chips avoid an N+1. Co-Authored-By: Claude Opus 4.8 --- app/services/event_dashboard.rb | 4 +++- app/views/events/recipients.html.erb | 16 ++++++++++++++-- spec/requests/events_spec.rb | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/services/event_dashboard.rb b/app/services/event_dashboard.rb index e3f999e827..6a799e87e2 100644 --- a/app/services/event_dashboard.rb +++ b/app/services/event_dashboard.rb @@ -53,7 +53,9 @@ def scholarship_recipient_count def scholarship_applicants @scholarship_applicants ||= Person .where(id: scholarship_applicant_ids) - .includes(:sectors, { categories: :category_type }, { affiliations: :organization }) + .includes(:sectors, { categories: :category_type }, + { categorizable_items: { category: :category_type } }, + { affiliations: :organization }) .sort_by(&:name) end diff --git a/app/views/events/recipients.html.erb b/app/views/events/recipients.html.erb index 886192931e..6d12321d03 100644 --- a/app/views/events/recipients.html.erb +++ b/app/views/events/recipients.html.erb @@ -79,6 +79,13 @@ then the additional sectors alphabetically. %> <% sectorable_items = person.sectorable_items_primary_first %> <% has_sectors = sectorable_items.any? %> + <%# Primary age groups first (starred amber chips), then the additional + ones — matching the sector chips above. Falls back to the form + answer / profile text only when the person carries no tagged age + groups. %> + <% primary_age_groups = person.primary_age_groups.to_a %> + <% additional_age_groups = person.additional_age_groups.to_a %> + <% has_age_groups = primary_age_groups.any? || additional_age_groups.any? %>