Browse Source

Add another bulk upload status for invalid uploads

pull/2883/head
Manny Dinssa 5 months ago
parent
commit
91564c5267
  1. 2
      app/helpers/tag_helper.rb
  2. 3
      app/models/bulk_upload.rb
  3. 3
      app/services/bulk_upload/processor.rb

2
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",

3
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?

3
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)

Loading…
Cancel
Save