diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb index becc2d213..159a07664 100644 --- a/app/helpers/logs_helper.rb +++ b/app/helpers/logs_helper.rb @@ -41,9 +41,15 @@ module LogsHelper end end - def pluralize_logs_and_errors_warning(log_count, error_count) - is_or_are = log_count == 1 ? "is" : "are" - need_or_needs = error_count == 1 ? "needs" : "need" - "There #{is_or_are} #{pluralize(log_count, 'log')} in this bulk upload with #{pluralize(error_count, 'error')} that still #{need_or_needs} to be fixed after upload." + def logs_and_errors_warning(bulk_upload) + this_or_these_errors = bulk_upload.bulk_upload_errors.count == 1 ? "This error" : "These errors" + + "You will upload #{pluralize(bulk_upload.total_logs_count, 'log')}. There are errors in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'error')} in total. #{this_or_these_errors} will need to be fixed on the CORE site." + end + + def logs_and_soft_validations_warning(bulk_upload) + this_or_these_unexpected_answers = bulk_upload.bulk_upload_errors.count == 1 ? "This unexpected answer" : "These unexpected answers" + + "You will upload #{pluralize(bulk_upload.total_logs_count, 'log')}. There are unexpected answers in #{pluralize(bulk_upload.logs_with_errors_count, 'log')}, and #{pluralize(bulk_upload.bulk_upload_errors.count, 'unexpected answer')} in total. #{this_or_these_unexpected_answers} will be marked as correct." end end diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 65a25507b..e98103b6d 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -107,6 +107,10 @@ class BulkUpload < ApplicationRecord end end + def logs_with_errors_count + bulk_upload_errors.distinct.count("row") + end + private def generate_identifier diff --git a/app/models/forms/bulk_upload_lettings_resume/fix_choice.rb b/app/models/forms/bulk_upload_lettings_resume/fix_choice.rb index 76ee10d17..cf86f2e16 100644 --- a/app/models/forms/bulk_upload_lettings_resume/fix_choice.rb +++ b/app/models/forms/bulk_upload_lettings_resume/fix_choice.rb @@ -39,9 +39,9 @@ module Forms def recommendation if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? - "For this many errors we recommend to fix errors in the CSV and re-upload as you may be able to edit many fields at once in a CSV." + "We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site." else - "For this many errors we recommend to upload logs and fix errors on site as you can easily see the questions and select the appropriate answer." + "We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV." end end diff --git a/app/models/forms/bulk_upload_sales_resume/fix_choice.rb b/app/models/forms/bulk_upload_sales_resume/fix_choice.rb index fc565e2f6..d26cd073d 100644 --- a/app/models/forms/bulk_upload_sales_resume/fix_choice.rb +++ b/app/models/forms/bulk_upload_sales_resume/fix_choice.rb @@ -39,9 +39,9 @@ module Forms def recommendation if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? - "For this many errors we recommend to fix errors in the CSV and re-upload as you may be able to edit many fields at once in a CSV." + "We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site." else - "For this many errors we recommend to upload logs and fix errors on site as you can easily see the questions and select the appropriate answer." + "We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV." end end diff --git a/app/views/bulk_upload_lettings_resume/confirm.html.erb b/app/views/bulk_upload_lettings_resume/confirm.html.erb index a2e3cef8e..841fd9e5e 100644 --- a/app/views/bulk_upload_lettings_resume/confirm.html.erb +++ b/app/views/bulk_upload_lettings_resume/confirm.html.erb @@ -5,12 +5,12 @@
Bulk upload for lettings (<%= @bulk_upload.year_combo %>) -

Are you sure you want to upload all logs from this bulk upload?

+

You have chosen to upload all logs from this bulk upload.

-

<%= pluralize_logs_and_errors_warning(@bulk_upload.logs.count, @bulk_upload.bulk_upload_errors.count) %>

+

<%= logs_and_errors_warning(@bulk_upload) %>

<%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> - <%= f.govuk_submit %> + <%= f.govuk_submit "Confirm" %> <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> <% end %> diff --git a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb index 05af0fd35..21a9dee99 100644 --- a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb @@ -4,24 +4,33 @@ <%= f.govuk_error_summary %> Bulk upload for lettings (<%= @bulk_upload.year_combo %>) -

How would you like to fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %>?

+

How would you like to fix the errors?

File: <%= @bulk_upload.filename %>
+
+ You have tried to upload <%= @bulk_upload.total_logs_count ? pluralize(@bulk_upload.total_logs_count, "log") : "logs" %>. There are errors in <%= pluralize(@bulk_upload.logs_with_errors_count, "log") %>, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in total. +
+
<%= @form.recommendation %>
<%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %> -

When it comes to fixing errors, there are pros and cons to doing it on a CSV versus doing it on a website.

- -

Fixing errors on a CSV file can be beneficial because it allows you to easily make changes to multiple records at once, and you can use tools like Excel to quickly identify and correct errors. However, if the CSV file is not properly formatted, it can be difficult to identify which records contain errors.

- -

Fixing errors on a website can be convenient because you can see the data in context and make changes in real-time. However, this approach can be time-consuming if you need to make changes to multiple records, and it may be more difficult to identify errors in a large dataset.

- -

Ultimately, the best approach will depend on the specific situation and the nature of the errors that need to be fixed.

+

You may find it easier to fix the errors in the CSV file if:

+ +

You may find it easier to fix the errors on the CORE site if:

+ <% end %> <%= f.govuk_collection_radio_buttons :choice, diff --git a/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb b/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb index 095bf77b4..fcb039eac 100644 --- a/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb +++ b/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb @@ -5,9 +5,9 @@
Bulk upload for lettings (<%= @bulk_upload.year_combo %>) -

Are you sure you want to upload all logs from this bulk upload?

+

You have chosen to upload all logs from this bulk upload.

-

There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "unexpected answer") %> will be marked as correct.

+

<%= logs_and_soft_validations_warning(@bulk_upload) %>

<%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= f.govuk_submit %> diff --git a/app/views/bulk_upload_sales_resume/confirm.html.erb b/app/views/bulk_upload_sales_resume/confirm.html.erb index e0081f46b..05a8cfd41 100644 --- a/app/views/bulk_upload_sales_resume/confirm.html.erb +++ b/app/views/bulk_upload_sales_resume/confirm.html.erb @@ -5,9 +5,9 @@
Bulk upload for sales (<%= @bulk_upload.year_combo %>) -

Are you sure you want to upload all logs from this bulk upload?

+

You have chosen to upload all logs from this bulk upload.

-

There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload with <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> that still need to be fixed after upload.

+

<%= logs_and_errors_warning(@bulk_upload) %>

<%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= f.govuk_submit %> diff --git a/app/views/bulk_upload_sales_resume/fix_choice.html.erb b/app/views/bulk_upload_sales_resume/fix_choice.html.erb index 050eb4da2..d0c8868c8 100644 --- a/app/views/bulk_upload_sales_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_sales_resume/fix_choice.html.erb @@ -4,24 +4,33 @@ <%= f.govuk_error_summary %> Bulk upload for sales (<%= @bulk_upload.year_combo %>) -

How would you like to fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %>?

+

How would you like to fix the errors?

File: <%= @bulk_upload.filename %>
+
+ You have tried to upload <%= @bulk_upload.total_logs_count ? pluralize(@bulk_upload.total_logs_count, "log") : "logs" %>. There are errors in <%= pluralize(@bulk_upload.logs_with_errors_count, "log") %>, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in total. +
+
<%= @form.recommendation %>
<%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %> -

When it comes to fixing errors, there are pros and cons to doing it on a CSV versus doing it on a website.

- -

Fixing errors on a CSV file can be beneficial because it allows you to easily make changes to multiple records at once, and you can use tools like Excel to quickly identify and correct errors. However, if the CSV file is not properly formatted, it can be difficult to identify which records contain errors.

- -

Fixing errors on a website can be convenient because you can see the data in context and make changes in real-time. However, this approach can be time-consuming if you need to make changes to multiple records, and it may be more difficult to identify errors in a large dataset.

- -

Ultimately, the best approach will depend on the specific situation and the nature of the errors that need to be fixed.

+

You may find it easier to fix the errors in the CSV file if:

+
    +
  • you have a lot of errors
  • +
  • the CSV file is formatted incorrectly and you can see where the errors are
  • +
  • you need to fix multiple errors at once
  • +
+

You may find it easier to fix the errors on the CORE site if:

+
    +
  • you need to see the data in context
  • +
  • you have a smaller file, with a few errors
  • +
  • you are not sure where the errors are
  • +
<% end %> <%= f.govuk_collection_radio_buttons :choice, diff --git a/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb b/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb index 11c69c1eb..ca9f7fd4f 100644 --- a/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb +++ b/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb @@ -5,9 +5,9 @@
Bulk upload for sales (<%= @bulk_upload.year_combo %>) -

Are you sure you want to upload all logs from this bulk upload?

+

You have chosen to upload all logs from this bulk upload.

-

There are <%= pluralize(@bulk_upload.logs.count, "log") %> in this bulk upload, and <%= pluralize(@bulk_upload.bulk_upload_errors.count, "unexpected answer") %> will be marked as correct.

+

<%= logs_and_soft_validations_warning(@bulk_upload) %>

<%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_soft_validations_check_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> <%= f.govuk_submit %> diff --git a/spec/requests/bulk_upload_lettings_resume_controller_spec.rb b/spec/requests/bulk_upload_lettings_resume_controller_spec.rb index 7ba8bbc85..fddba7190 100644 --- a/spec/requests/bulk_upload_lettings_resume_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_resume_controller_spec.rb @@ -25,7 +25,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response.body).to include("Bulk upload for lettings") expect(response.body).to include("2022/23") - expect(response.body).to include("How would you like to fix 2 errors?") + expect(response.body).to include("How would you like to fix the errors?") expect(response.body).to include(bulk_upload.filename) expect(response.body).not_to include("Cancel") end @@ -106,7 +106,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Are you sure") + expect(response.body).to include("You have chosen to upload all logs from this bulk upload.") end it "sets no cache headers" do diff --git a/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb b/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb index 0603e3d34..904c18573 100644 --- a/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request do let(:user) { create(:user) } - let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:) } + let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:, total_logs_count: 2) } let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) } before do @@ -98,8 +98,8 @@ RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request expect(response).to be_successful - expect(response.body).to include("Are you sure you want to upload all logs from this bulk upload?") - expect(response.body).to include("There are 2 logs in this bulk upload, and 2 unexpected answers will be marked as correct.") + expect(response.body).to include("You have chosen to upload all logs from this bulk upload.") + expect(response.body).to include("You will upload 2 logs. There are unexpected answers in 2 logs, and 2 unexpected answers in total. These unexpected answers will be marked as correct.") expect(response.body).not_to include("You’ve successfully uploaded") end end diff --git a/spec/requests/bulk_upload_sales_resume_controller_spec.rb b/spec/requests/bulk_upload_sales_resume_controller_spec.rb index 9c0a7112c..9e4ec4a2b 100644 --- a/spec/requests/bulk_upload_sales_resume_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_resume_controller_spec.rb @@ -25,7 +25,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response.body).to include("Bulk upload for sales") expect(response.body).to include("2022/23") - expect(response.body).to include("How would you like to fix 2 errors?") + expect(response.body).to include("How would you like to fix the errors?") expect(response.body).to include(bulk_upload.filename) expect(response.body).not_to include("Cancel") end @@ -106,7 +106,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Are you sure") + expect(response.body).to include("You have chosen to upload all logs from this bulk upload.") end it "sets no cache headers" do diff --git a/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb b/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb index 0b496aea4..3225f0f3f 100644 --- a/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do let(:user) { create(:user) } - let(:bulk_upload) { create(:bulk_upload, :sales, user:, bulk_upload_errors:) } + let(:bulk_upload) { create(:bulk_upload, :sales, user:, bulk_upload_errors:, total_logs_count: 2) } let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) } before do @@ -98,8 +98,8 @@ RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do expect(response).to be_successful - expect(response.body).to include("Are you sure you want to upload all logs from this bulk upload?") - expect(response.body).to include("There are 2 logs in this bulk upload, and 2 unexpected answers will be marked as correct.") + expect(response.body).to include("You have chosen to upload all logs from this bulk upload.") + expect(response.body).to include("You will upload 2 logs. There are unexpected answers in 2 logs, and 2 unexpected answers in total. These unexpected answers will be marked as correct.") expect(response.body).not_to include("You’ve successfully uploaded") end end