Browse Source

speed up bulk upload with missing memoization (#1539)

pull/1542/head
Phil Lee 2 years ago committed by GitHub
parent
commit
d47c4bcdc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  2. 6
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  3. 6
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

6
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -340,10 +340,10 @@ class BulkUpload::Lettings::Year2022::RowParser
return true if blank_row?
super
log.valid?
super
log.errors.each do |error|
fields = field_mapping_for_errors[error.attribute] || []
@ -650,7 +650,7 @@ private
end
def questions
log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
@questions ||= log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
end
def validate_nulls

6
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -342,10 +342,10 @@ class BulkUpload::Lettings::Year2023::RowParser
return true if blank_row?
super
log.valid?
super
log.errors.each do |error|
fields = field_mapping_for_errors[error.attribute] || []
@ -826,7 +826,7 @@ private
end
def questions
log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
@questions ||= log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
end
def attributes_for_log

6
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -844,12 +844,12 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end
end
describe "#field_56" do # age3
describe "#field_52" do # age2
context "when null but gender given" do
let(:attributes) { setup_section_params.merge({ field_56: "", field_57: "F" }) }
let(:attributes) { setup_section_params.merge({ field_52: "", field_53: "F" }) }
it "returns an error" do
expect(parser.errors[:field_56]).to be_present
expect(parser.errors[:field_52]).to be_present
end
end
end

Loading…
Cancel
Save