Skip to content

Commit

Permalink
Merge pull request #714 from bitzesty/statistics-table
Browse files Browse the repository at this point in the history
Fix: Statistics table QA amendments
  • Loading branch information
TheDancingClown authored Aug 28, 2024
2 parents ea2df1c + 10810b4 commit bb762e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
29 changes: 3 additions & 26 deletions app/search/nomination_stats_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
6 changes: 2 additions & 4 deletions app/views/admin/statistics/nomination_mailer/notify.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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


2 changes: 1 addition & 1 deletion app/views/admin/statistics/nominations/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit bb762e9

Please sign in to comment.