Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class BulkUploadErrorSummaryTableComponent < ViewComponent::Base
|
|
|
|
DISPLAY_THRESHOLD = 16
|
|
|
|
|
|
|
|
attr_reader :bulk_upload
|
|
|
|
|
|
|
|
def initialize(bulk_upload:)
|
|
|
|
@bulk_upload = bulk_upload
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def sorted_errors
|
|
|
|
@sorted_errors ||= bulk_upload
|
|
|
|
.bulk_upload_errors
|
|
|
|
.group(:col, :field, :error)
|
|
|
|
.having("count(*) > ?", display_threshold)
|
|
|
|
.count
|
|
|
|
.sort_by { |el| el[0][0].rjust(3, "0") }
|
|
|
|
end
|
|
|
|
|
|
|
|
def errors?
|
|
|
|
sorted_errors.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def display_threshold
|
|
|
|
DISPLAY_THRESHOLD
|
|
|
|
end
|
|
|
|
end
|