From d869dce24b8e5e0bd61719ef8a3d323185fee219 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Thu, 16 Feb 2023 18:59:02 +0000 Subject: [PATCH] chore: lint --- app/mailers/bulk_upload_mailer.rb | 4 ++-- app/services/bulk_upload/lettings/row_parser.rb | 6 +++--- app/services/bulk_upload/lettings/validator.rb | 4 ++-- app/services/bulk_upload/processor.rb | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/mailers/bulk_upload_mailer.rb b/app/mailers/bulk_upload_mailer.rb index a6ab8951b..90336e0e2 100644 --- a/app/mailers/bulk_upload_mailer.rb +++ b/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 diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index ef969581f..82a7cb352 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/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 diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb index 741c1b026..1b3f48cf8 100644 --- a/app/services/bulk_upload/lettings/validator.rb +++ b/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:) diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index c9c3c1224..2d8aadfa0 100644 --- a/app/services/bulk_upload/processor.rb +++ b/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