Browse Source

Rubocop

pull/96/head
baarkerlounger 4 years ago
parent
commit
c68ba05f3f
  1. 10
      app/models/bulk_upload.rb
  2. 11
      db/migrate/20211116102527_change_datetime.rb
  3. 4
      db/schema.rb

10
app/models/bulk_upload.rb

@ -26,12 +26,14 @@ class BulkUpload
else else
data_range = FIRST_DATA_ROW..last_row data_range = FIRST_DATA_ROW..last_row
data_range.map do |row_num| data_range.map do |row_num|
case_log = CaseLog.create case_log = CaseLog.create!
map_row(sheet.row(row_num)).each do |attr_key, attr_val| map_row(sheet.row(row_num)).each do |attr_key, attr_val|
begin update = case_log.update(attr_key => attr_val)
case_log.update_attribute(attr_key, attr_val) unless update.persisted?
rescue ArgumentError # TODO: determine what to do when a bulk upload contains field values that don't pass validations
end end
rescue ArgumentError
# TODO: determine what we want to do when bulk upload contains totally invalid data for a field.
end end
end end
end end

11
db/migrate/20211116102527_change_datetime.rb

@ -1,5 +1,5 @@
class ChangeDatetime < ActiveRecord::Migration[6.1] class ChangeDatetime < ActiveRecord::Migration[6.1]
def change def up
change_table :case_logs, bulk: true do |t| change_table :case_logs, bulk: true do |t|
t.remove :sale_completion_date t.remove :sale_completion_date
t.column :sale_completion_date, :datetime t.column :sale_completion_date, :datetime
@ -7,4 +7,13 @@ class ChangeDatetime < ActiveRecord::Migration[6.1]
t.column :startdate, :datetime t.column :startdate, :datetime
end end
end end
def down
change_table :case_logs, bulk: true do |t|
t.remove :sale_completion_date
t.column :sale_completion_date, :string
t.remove :startdate
t.column :startdate, :string
end
end
end end

4
db/schema.rb

@ -121,6 +121,8 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do
t.integer "rp_dontknow" t.integer "rp_dontknow"
t.datetime "discarded_at" t.datetime "discarded_at"
t.string "tenancyother" t.string "tenancyother"
t.integer "override_net_income_validation"
t.string "net_income_known"
t.string "gdpr_acceptance" t.string "gdpr_acceptance"
t.string "gdpr_declined" t.string "gdpr_declined"
t.string "property_owner_organisation" t.string "property_owner_organisation"
@ -131,8 +133,6 @@ ActiveRecord::Schema.define(version: 2021_11_16_102527) do
t.string "intermediate_rent_product_name" t.string "intermediate_rent_product_name"
t.string "needs_type" t.string "needs_type"
t.string "purchaser_code" t.string "purchaser_code"
t.integer "override_net_income_validation"
t.string "net_income_known"
t.integer "reason" t.integer "reason"
t.string "propcode" t.string "propcode"
t.integer "majorrepairs" t.integer "majorrepairs"

Loading…
Cancel
Save