From d65b18d48f04bceb1d770410cd75ab3462b07edf Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 30 Jan 2023 09:30:26 +0000 Subject: [PATCH] persist column for bulk upload errors (#1239) --- app/services/bulk_upload/lettings/validator.rb | 1 + .../20230126145529_add_column_to_bulk_upload_errors.rb | 5 +++++ db/schema.rb | 3 ++- spec/services/bulk_upload/lettings/validator_spec.rb | 9 ++++++++- 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20230126145529_add_column_to_bulk_upload_errors.rb diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb index 8cfdee684..b96739836 100644 --- a/app/services/bulk_upload/lettings/validator.rb +++ b/app/services/bulk_upload/lettings/validator.rb @@ -164,6 +164,7 @@ class BulkUpload::Lettings::Validator property_ref: row_parser.field_100, row:, cell: "#{cols[field_number_for_attribute(error.attribute) - col_offset + 1]}#{row}", + col: cols[field_number_for_attribute(error.attribute) - col_offset + 1], ) end end diff --git a/db/migrate/20230126145529_add_column_to_bulk_upload_errors.rb b/db/migrate/20230126145529_add_column_to_bulk_upload_errors.rb new file mode 100644 index 000000000..437b5f2cd --- /dev/null +++ b/db/migrate/20230126145529_add_column_to_bulk_upload_errors.rb @@ -0,0 +1,5 @@ +class AddColumnToBulkUploadErrors < ActiveRecord::Migration[7.0] + def change + add_column :bulk_upload_errors, :col, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 8722ec6a4..fc060fc47 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_23_160741) do +ActiveRecord::Schema[7.0].define(version: 2023_01_26_145529) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -25,6 +25,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_23_160741) do t.text "error" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.text "col" t.index ["bulk_upload_id"], name: "index_bulk_upload_errors_on_bulk_upload_id" end diff --git a/spec/services/bulk_upload/lettings/validator_spec.rb b/spec/services/bulk_upload/lettings/validator_spec.rb index e242858bf..661119448 100644 --- a/spec/services/bulk_upload/lettings/validator_spec.rb +++ b/spec/services/bulk_upload/lettings/validator_spec.rb @@ -43,7 +43,14 @@ RSpec.describe BulkUpload::Lettings::Validator do validator.call error = BulkUploadError.first - expect(error.row).to eq("7") + + expect(error.field).to eql("field_96") + expect(error.error).to eql("blank") + expect(error.tenant_code).to eql("123") + expect(error.property_ref).to be_nil + expect(error.row).to eql("7") + expect(error.cell).to eql("CS7") + expect(error.col).to eql("CS") end end