|
|
|
@ -1,5 +1,3 @@ |
|
|
|
require "csv" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BulkUpload::Lettings::Validator |
|
|
|
class BulkUpload::Lettings::Validator |
|
|
|
include ActiveModel::Validations |
|
|
|
include ActiveModel::Validations |
|
|
|
|
|
|
|
|
|
|
|
@ -68,19 +66,6 @@ class BulkUpload::Lettings::Validator |
|
|
|
errors.count == errors.where(category: "soft_validation").count && errors.count.positive? |
|
|
|
errors.count == errors.where(category: "soft_validation").count && errors.count.positive? |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def over_column_error_threshold? |
|
|
|
|
|
|
|
fields = ("field_1".."field_134").to_a |
|
|
|
|
|
|
|
percentage_threshold = (row_parsers.size * COLUMN_PERCENTAGE_ERROR_THRESHOLD).ceil |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fields.any? do |field| |
|
|
|
|
|
|
|
count = row_parsers.count { |row_parser| row_parser.errors[field].present? } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next if count < COLUMN_ABSOLUTE_ERROR_THRESHOLD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count > percentage_threshold |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def any_logs_already_exist? |
|
|
|
def any_logs_already_exist? |
|
|
|
row_parsers.any?(&:log_already_exists?) |
|
|
|
row_parsers.any?(&:log_already_exists?) |
|
|
|
end |
|
|
|
end |
|
|
|
|