Browse Source

refactor: simplify

pull/2142/head
natdeanlewissoftwire 2 years ago
parent
commit
908e81f2c8
  1. 12
      app/helpers/logs_helper.rb
  2. 2
      app/views/bulk_upload_lettings_results/deletion_report.html.erb

12
app/helpers/logs_helper.rb

@ -66,10 +66,14 @@ module LogsHelper
end end
def deleted_errors_warning_text(bulk_upload) def deleted_errors_warning_text(bulk_upload)
unique_field_count = bulk_upload.bulk_upload_errors.uniq(&:field).count unique_answers_to_be_cleared_count = unique_answers_to_be_cleared(bulk_upload).count
this_or_these = unique_field_count == 1 ? "this" : "these" this_or_these = unique_answers_to_be_cleared_count == 1 ? "this" : "these"
it_is_or_they_are = unique_field_count == 1 ? "it is" : "they are" it_is_or_they_are = unique_answers_to_be_cleared_count == 1 ? "it is" : "they are"
"#{pluralize(unique_field_count, 'answer')} will be deleted because #{it_is_or_they_are} invalid. You will have to answer #{this_or_these} #{'question'.pluralize(unique_field_count)} again on the site." "#{pluralize(unique_answers_to_be_cleared_count, 'answer')} will be deleted because #{it_is_or_they_are} invalid. You will have to answer #{this_or_these} #{'question'.pluralize(unique_answers_to_be_cleared_count)} again on the site."
end
def unique_answers_to_be_cleared(bulk_upload)
bulk_upload.bulk_upload_errors.reject { |e| e.category == :not_answered }.uniq(&:field)
end end
end end

2
app/views/bulk_upload_lettings_results/deletion_report.html.erb

@ -5,7 +5,7 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span> <span class="govuk-caption-l">Bulk upload for lettings (<%= @bulk_upload.year_combo %>)</span>
<h1 class="govuk-heading-l"><%= @bulk_upload.bulk_upload_errors.reject { |e| e.category == :not_answered }.uniq(&:field).count == 1 ? "This" : "These" %> <%= pluralize(@bulk_upload.bulk_upload_errors.reject { |e| e.category == :not_answered }.uniq(&:field).count, "answer") %> will be deleted if you upload the <%= "log".pluralize(@bulk_upload.logs.count) %></h1> <h1 class="govuk-heading-l"><%= unique_answers_to_be_cleared(@bulk_upload).count == 1 ? "This" : "These" %> <%= pluralize(unique_answers_to_be_cleared(@bulk_upload).count, "answer") %> will be deleted if you upload the <%= "log".pluralize(@bulk_upload.logs.count) %></h1>
<p>The following cells contain data this is incorrect.</p> <p>The following cells contain data this is incorrect.</p>
<p>If you upload the logs, these answers will be deleted. You will have to re-enter the data on the site and resolve these errors.</p> <p>If you upload the logs, these answers will be deleted. You will have to re-enter the data on the site and resolve these errors.</p>

Loading…
Cancel
Save