Browse Source

chore: lint

cldc-1888-bulk-upload-duplicate-log-validation
Sam Seed 2 years ago
parent
commit
d869dce24b
  1. 4
      app/mailers/bulk_upload_mailer.rb
  2. 6
      app/services/bulk_upload/lettings/row_parser.rb
  3. 4
      app/services/bulk_upload/lettings/validator.rb
  4. 5
      app/services/bulk_upload/processor.rb

4
app/mailers/bulk_upload_mailer.rb

@ -64,10 +64,10 @@ class BulkUploadMailer < NotifyMailer
correct_and_reupload_description = "Please correct your data export and upload again."
if errors.size == 0
if errors.size.zero?
error_description = correct_and_reupload_description
else
error_description = "We noticed the following issues with your upload:\n\n" #{"s" if errors.size > 1}
error_description = "We noticed the following issues with your upload:\n\n" # {"s" if errors.size > 1}
errors.each { |error| error_description << "- #{error}\n" }
error_description << "\n"
end

6
app/services/bulk_upload/lettings/row_parser.rb

@ -182,7 +182,7 @@ class BulkUpload::Lettings::RowParser
end
def log_already_exists?
fields_for_duplicity_check = %w(
fields_for_duplicity_check = %w[
startdate
postcode_full
brent
@ -194,9 +194,9 @@ class BulkUpload::Lettings::RowParser
sex1
ecstat1
ethnic
)
]
LettingsLog.exists?(Hash[fields_for_duplicity_check.collect { |field| [field, log[field]] }])
LettingsLog.exists?(fields_for_duplicity_check.index_with { |field| log[field] })
end
private

4
app/services/bulk_upload/lettings/validator.rb

@ -204,14 +204,14 @@ class BulkUpload::Lettings::Validator
end
def any_logs_already_exist?
row_parsers.any? { |row_parser| row_parser.log_already_exists? }
row_parsers.any?(&:log_already_exists?)
end
def any_logs_invalid?
row_parsers.any? { |row_parser| row_parser.log.invalid? }
end
private
private
def csv_parser
@csv_parser ||= BulkUpload::Lettings::CsvParser.new(path:)

5
app/services/bulk_upload/processor.rb

@ -21,10 +21,9 @@ class BulkUpload::Processor
validator.any_setup_sections_incomplete?,
validator.over_column_error_threshold?,
validator.any_logs_already_exist?,
validator.any_logs_invalid?
validator.any_logs_invalid?,
)
end
rescue StandardError => e
Sentry.capture_exception(e)
send_failure_mail
@ -45,7 +44,7 @@ private
over_column_error_threshold,
any_logs_already_exist,
any_logs_invalid,
bulk_upload:
bulk_upload:,
).deliver_later
end

Loading…
Cancel
Save