From 91564c52676fd1b2e4a7a1ba16b9c09bdfc21bbf Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Mon, 6 Jan 2025 09:36:46 +0000 Subject: [PATCH] Add another bulk upload status for invalid uploads --- app/helpers/tag_helper.rb | 2 ++ app/models/bulk_upload.rb | 3 ++- app/services/bulk_upload/processor.rb | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/helpers/tag_helper.rb b/app/helpers/tag_helper.rb index 398f897cf..7e7353157 100644 --- a/app/helpers/tag_helper.rb +++ b/app/helpers/tag_helper.rb @@ -21,6 +21,7 @@ module TagHelper processing: "Processing", blank_template: "Blank template", wrong_template: "Wrong template used", + invalid_upload: "Invalid upload", important_errors: "Errors on important questions in CSV", critical_errors: "Critical errors in CSV", potential_errors: "Potential errors in CSV", @@ -48,6 +49,7 @@ module TagHelper processing: "yellow", blank_template: "red", wrong_template: "red", + invalid_upload: "red", important_errors: "red", critical_errors: "red", potential_errors: "red", diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 3a3d41540..c66d6ba12 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -1,7 +1,7 @@ class BulkUpload < ApplicationRecord enum :log_type, { lettings: "lettings", sales: "sales" } enum :rent_type_fix_status, { not_applied: "not_applied", applied: "applied", not_needed: "not_needed" } - enum :failure_reason, { blank_template: "blank_template", wrong_template: "wrong_template" } + enum :failure_reason, { blank_template: "blank_template", wrong_template: "wrong_template", invalid_upload: "invalid_upload" } belongs_to :user @@ -43,6 +43,7 @@ class BulkUpload < ApplicationRecord return :processing if processing return :blank_template if failure_reason == "blank_template" return :wrong_template if failure_reason == "wrong_template" + return :invalid_upload if failure_reason == "invalid_upload" if logs.visible.exists? return :errors_fixed_in_service if completed? && bulk_upload_errors.any? diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index c54032fda..19cd6a398 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -61,6 +61,7 @@ class BulkUpload::Processor end rescue StandardError => e Sentry.capture_exception(e) + @bulk_upload.update!(failure_reason: "invalid_upload") send_failure_mail ensure downloader.delete_local_file! @@ -184,6 +185,8 @@ private @bulk_upload.update!(failure_reason: "blank_template") elsif wrong_template_errors.any? { |error| validator.errors.full_messages.include?(error) } @bulk_upload.update!(failure_reason: "wrong_template") + else + @bulk_upload.update!(failure_reason: "invalid_upload") end send_failure_mail(errors: validator.errors.full_messages)