From 13651e395139e2b405f2b1eecf0c2b9b84a90f85 Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Tue, 27 Aug 2024 13:29:07 +0100 Subject: [PATCH 1/2] chore: Update email layout and styling for nomination statistics report Signed-off-by: Louis Kirkham --- .../admin/statistics/nomination_mailer/notify.text.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/admin/statistics/nomination_mailer/notify.text.erb b/app/views/admin/statistics/nomination_mailer/notify.text.erb index 1324b30b8..62c1a7e9c 100644 --- a/app/views/admin/statistics/nomination_mailer/notify.text.erb +++ b/app/views/admin/statistics/nomination_mailer/notify.text.erb @@ -2,11 +2,9 @@ Dear <%= @admin.first_name %>, You requested an export of nomination statistics. -Please find this report on the link below: +Please find this report on the link below: <%= admin_protected_file_url(@file) %> -Kind Regards, +Kind regards, The King's Awards Office - - From 10810b4a406f494f850d2fbf2e7eff3876127cff Mon Sep 17 00:00:00 2001 From: Louis Kirkham Date: Wed, 28 Aug 2024 07:57:56 +0100 Subject: [PATCH 2/2] chore: Use existing code for lieutenancy filter Signed-off-by: Louis Kirkham --- app/search/nomination_stats_search.rb | 29 ++----------------- .../statistics/nominations/index.html.slim | 2 +- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/app/search/nomination_stats_search.rb b/app/search/nomination_stats_search.rb index 31f4f3213..cd05edb16 100644 --- a/app/search/nomination_stats_search.rb +++ b/app/search/nomination_stats_search.rb @@ -11,9 +11,9 @@ class NominationStatsSearch < Search shortlisted awarded ] - + FETCH_QUERY = %Q{ - CASE WHEN ceremonial_counties.name IS NULL THEN '-' ELSE ceremonial_counties.name END AS ceremonial_county_name, + CASE WHEN ceremonial_counties.name IS NULL THEN 'Not assigned' ELSE ceremonial_counties.name END AS ceremonial_county_name, #{TRACKED_STATES.map { |s| "COUNT(CASE WHEN form_answers.state = '#{s}' THEN 1 END) AS #{s}_count" }.join(',')}, COUNT(CASE WHEN form_answers.state IN (#{TRACKED_STATES.map { |s| "'#{s}'" }.join(',')}) THEN 1 END) AS total_count }.squish.freeze @@ -23,7 +23,7 @@ def self.default_search sort: "ceremonial_county_name", search_filter: { year: "all_years", - assigned_ceremonial_county: ceremonial_county_options.map(&:second) + assigned_ceremonial_county: FormAnswerStatus::AdminFilter.values('assigned county') } } end @@ -58,27 +58,4 @@ def sort_by_ceremonial_county_name(scoped_results, desc = false) scoped_results.order("ceremonial_counties.name #{sort_order(desc)}") end - class << self - def ceremonial_county_options - collection_mapping(county_options) - end - - private - - def collection_mapping(options) - options.map do |k, v| - [v[:label], k] - end - end - - def county_options - options = Hash[not_assigned: { label: "Not assigned" }] - - CeremonialCounty.ordered.collect do |county| - options[county.id] = { label: county.name } - end - - options - end - end end diff --git a/app/views/admin/statistics/nominations/index.html.slim b/app/views/admin/statistics/nominations/index.html.slim index 2a9c77720..5dc75466c 100644 --- a/app/views/admin/statistics/nominations/index.html.slim +++ b/app/views/admin/statistics/nominations/index.html.slim @@ -12,7 +12,7 @@ h1.govuk-heading-xl ' Award year = g.select :year, award_years_collection, {}, { id: "award-year-select", class: "govuk-select custom-select", style: "height: 40px;", aria: { label: "award year select" } } - = render "shared/form_answers/filters/assigned_lieutenancy_filter", g: g, options: NominationStatsSearch.ceremonial_county_options + = render "shared/form_answers/filters/assigned_lieutenancy_filter", g: g, options: FormAnswerStatus::AdminFilter.collection('assigned county') div[class="govuk-button-group"] = f.submit "Apply filters",