Skip to content

Commit 05b953b

Browse files
Merge pull request #5979 from nhsuk/alistair/national-reporting-upload-numbers
Show better stats to national reporting uploads
2 parents dc3a8be + a5c393c commit 05b953b

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
class AppImportStatisticsComponent < ViewComponent::Base
4+
erb_template <<-ERB
5+
<p><strong>Out of <%= pluralize(@import.rows_count, "record") %> found in the file:</strong></p>
6+
<ul>
7+
<li><%= pluralize(@import.new_record_count, "new record") %> imported</li>
8+
<li><%= pluralize(@import.exact_duplicate_record_count, "duplicate") %> not imported</li>
9+
<li><%= pluralize(@import.ignored_record_count, "'not vaccinated' record") %> not imported</li>
10+
</ul>
11+
ERB
12+
13+
def initialize(import:)
14+
@import = import
15+
end
16+
end

app/components/app_import_summary_component.html.erb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@
4949
<% end %>
5050

5151
<% if import.records_count && import.records_count.positive? %>
52+
<% if import.is_a?(ImmunisationImport) && import.type == "national_reporting" %>
5253
<%= summary_list.with_row do |row| %>
53-
<%= row.with_key { "Records" } %>
54-
<%= row.with_value { import.records_count.to_s } %>
54+
<%= row.with_key { "Import summary" } %>
55+
<%= row.with_value { render AppImportStatisticsComponent.new(import: import) } %>
5556
<% end %>
57+
<% else %>
58+
<%= summary_list.with_row do |row| %>
59+
<%= row.with_key { "Records" } %>
60+
<%= row.with_value { import.records_count.to_s } %>
61+
<% end %>
62+
<% end %>
5663
<% end %>
5764
<% end %>
5865

spec/features/import_vaccination_records_national_reporting_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
when_i_go_back_to_the_upload_page
2828
and_i_upload_a_valid_mixed_file
2929
then_i_should_see_the_upload
30+
and_i_should_see_some_stats_about_the_import
3031
and_i_should_see_the_vaccination_records
3132
and_the_patients_should_now_be_associated_with_the_team
3233
and_the_newly_created_patients_should_be_archived
@@ -183,6 +184,13 @@ def then_i_should_see_the_upload
183184
expect(page).to have_content("Uploaded byUSER, Test")
184185
end
185186

187+
def and_i_should_see_some_stats_about_the_import
188+
expect(page).to have_content("Out of 3 records found in the file:")
189+
expect(page).to have_content("2 new records imported")
190+
expect(page).to have_content("0 duplicates not imported")
191+
expect(page).to have_content("1 'not vaccinated' record not imported")
192+
end
193+
186194
def and_the_patients_should_now_be_associated_with_the_team
187195
Patient.all.find_each { |patient| expect(patient.teams).to include(@team) }
188196
end

spec/features/national_reporting_team_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
and_i_should_see_the_national_reporting_service_guide_link
1212
end
1313

14-
scenario "Navigation shows only import, children and your team" do
14+
scenario "Navigation shows only import and children tabs" do
1515
given_i_am_signed_in_as_an_national_reporting_team
1616
when_i_visit_the_dashboard
1717
then_i_should_see_only_import_and_children_navigation_items

0 commit comments

Comments
 (0)