From fa621d762adae7f17136f1b3ec48e81188871092 Mon Sep 17 00:00:00 2001
From: diti
Date: Fri, 13 Feb 2026 20:33:32 +0100
Subject: [PATCH 1/4] Add population served page to organisation
---
.../organizations/populations_served.html.erb | 25 +++++++++++++++++++
app/views/organizations/show.html.erb | 6 +++++
config/routes.rb | 10 ++++++++
3 files changed, 41 insertions(+)
create mode 100644 app/views/organizations/populations_served.html.erb
diff --git a/app/views/organizations/populations_served.html.erb b/app/views/organizations/populations_served.html.erb
new file mode 100644
index 000000000..26fe57e79
--- /dev/null
+++ b/app/views/organizations/populations_served.html.erb
@@ -0,0 +1,25 @@
+
+
+ Populations Served for <%= @organization.name %>
+
+
+ <% if @sectors_by_people.any? %>
+
+ <% @sectors_by_people.each do |sector, count| %>
+ -
+ <%= sector.name %>
+
+ <%= count %> <%= count == 1 ? "person" : "people" %>
+
+
+ <% end %>
+
+ <% else %>
+
No sectors found for this organization.
+ <% end %>
+
+
+ <%= link_to "← Back to Organization", organization_path(@organization),
+ class: "btn btn-secondary-outline" %>
+
+
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb
index eb59b6047..53cce4f92 100644
--- a/app/views/organizations/show.html.erb
+++ b/app/views/organizations/show.html.erb
@@ -120,9 +120,15 @@
None selected.
<% end %>
+
+ <%= link_to "Populations served",
+ populations_served_organization_path(@organization),
+ class: "inline-block px-4 py-2 bg-gray-100 border border-gray-300 rounded shadow-sm text-gray-800 hover:bg-gray-200 transition" %>
+
<% end %>
+
<% if true || @organization.profile_show_email? || @organization.profile_show_phone? %>
diff --git a/config/routes.rb b/config/routes.rb
index 30db9e42a..40d68521a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -63,6 +63,16 @@
resources :faqs
resources :notifications, only: [ :index, :show ]
resources :organizations
+ resources :notifications, only: [ :index, :show ] do
+ member do
+ post :resend
+ end
+ end
+ resources :organizations do
+ member do
+ get :populations_served
+ end
+ end
resources :organization_statuses
resources :organization_users
resources :quotes
From 5820d8ff8ba6944777e9a67b3cbbe548a57f30d5 Mon Sep 17 00:00:00 2001
From: diti
Date: Fri, 13 Feb 2026 20:57:39 +0100
Subject: [PATCH 2/4] Add organisation controller
---
app/controllers/organizations_controller.rb | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 896740bed..6d2c3b832 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -1,6 +1,6 @@
class OrganizationsController < ApplicationController
include AhoyTracking
- before_action :set_organization, only: [ :show, :edit, :update, :destroy ]
+ before_action :set_organization, only: [ :show, :edit, :update, :destroy, :populations_served]
def index
authorize!
@@ -98,6 +98,19 @@ def set_index_variables
@organization_statuses = OrganizationStatus.all
end
+ def populations_served
+ authorize! @organization
+
+ people = @organization.users.includes(:person).map(&:person).compact
+
+ sector_counts = Hash.new(0)
+ people.each do |person|
+ primary_sector = person.sectors.first
+ sector_counts[primary_sector] += 1 if primary_sector
+ end
+ @sectors_by_people = sector_counts.sort_by { |_sector, count| -count }
+end
+
private
def set_organization
From c1ed1992981415b09a9875abfa24d889fa52907d Mon Sep 17 00:00:00 2001
From: diti
Date: Fri, 13 Feb 2026 21:20:08 +0100
Subject: [PATCH 3/4] RuboCop
---
app/controllers/organizations_controller.rb | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 6d2c3b832..b62f21826 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -1,6 +1,6 @@
class OrganizationsController < ApplicationController
include AhoyTracking
- before_action :set_organization, only: [ :show, :edit, :update, :destroy, :populations_served]
+ before_action :set_organization, only: [ :show, :edit, :update, :destroy, :populations_served ]
def index
authorize!
@@ -99,16 +99,16 @@ def set_index_variables
end
def populations_served
- authorize! @organization
+ authorize! @organization
- people = @organization.users.includes(:person).map(&:person).compact
+ people = @organization.users.includes(:person).map(&:person).compact
- sector_counts = Hash.new(0)
- people.each do |person|
- primary_sector = person.sectors.first
- sector_counts[primary_sector] += 1 if primary_sector
- end
- @sectors_by_people = sector_counts.sort_by { |_sector, count| -count }
+ sector_counts = Hash.new(0)
+ people.each do |person|
+ primary_sector = person.sectors.first
+ sector_counts[primary_sector] += 1 if primary_sector
+ end
+ @sectors_by_people = sector_counts.sort_by { |_sector, count| -count }
end
private
From c03e4984b48092289558420da36378804576a612 Mon Sep 17 00:00:00 2001
From: diti
Date: Sat, 14 Feb 2026 18:15:38 +0100
Subject: [PATCH 4/4] Align terminology with Sector naming
---
app/views/organizations/populations_served.html.erb | 2 +-
app/views/organizations/show.html.erb | 2 +-
config/routes.rb | 6 ------
3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/app/views/organizations/populations_served.html.erb b/app/views/organizations/populations_served.html.erb
index 26fe57e79..7c1a42300 100644
--- a/app/views/organizations/populations_served.html.erb
+++ b/app/views/organizations/populations_served.html.erb
@@ -1,6 +1,6 @@
- Populations Served for <%= @organization.name %>
+ Sector Distribution for <%= @organization.name %>
<% if @sectors_by_people.any? %>
diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb
index 8dd5e8cbf..50a18919c 100644
--- a/app/views/organizations/show.html.erb
+++ b/app/views/organizations/show.html.erb
@@ -110,7 +110,7 @@
<% end %>
- <%= link_to "Populations served",
+ <%= link_to "Sector Distribution",
populations_served_organization_path(@organization),
class: "inline-block px-4 py-2 bg-gray-100 border border-gray-300 rounded shadow-sm text-gray-800 hover:bg-gray-200 transition" %>
diff --git a/config/routes.rb b/config/routes.rb
index 9a85dd441..8613a4203 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -82,12 +82,6 @@
post :resend
end
end
- resources :organizations
- resources :notifications, only: [ :index, :show ] do
- member do
- post :resend
- end
- end
resources :organizations do
member do
get :populations_served