diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index dc862529e..ad76c2192 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -47,11 +47,11 @@ class BulkUpload < ApplicationRecord return :logs_uploaded_with_errors if bulk_upload_errors.any? end - if bulk_upload_errors.any? { |error| error.category == "setup" } + if bulk_upload_errors.important.any? :important_errors - elsif bulk_upload_errors.any? { |error| error.category.nil? || error.category == "not_answered" } + elsif bulk_upload_errors.critical.any? :critical_errors - elsif bulk_upload_errors.any? { |error| error.category == "soft_validation" } + elsif bulk_upload_errors.potential.any? :potential_errors else :logs_uploaded_no_errors diff --git a/app/models/bulk_upload_error.rb b/app/models/bulk_upload_error.rb index c9ca14b0f..154fca2fc 100644 --- a/app/models/bulk_upload_error.rb +++ b/app/models/bulk_upload_error.rb @@ -4,4 +4,8 @@ class BulkUploadError < ApplicationRecord scope :order_by_row, -> { order("row::integer ASC") } scope :order_by_cell, -> { order(Arel.sql("LPAD(cell, 10, '0')")) } scope :order_by_col, -> { order(Arel.sql("LPAD(col, 10, '0')")) } + scope :important, -> { where(category: "setup") } + scope :potential, -> { where(category: "soft_validation") } + scope :critical, -> { where(category: nil).or(where.not(category: %w[setup soft_validation])) } + scope :critical_or_important, -> { critical.or(important) } end