From cfe81d6e65d5fa1cc18aa8600ada2ccc30795d4c Mon Sep 17 00:00:00 2001 From: Ilya Konanykhin Date: Mon, 20 Mar 2017 00:38:24 +0600 Subject: [PATCH] BikeCsvImporter: add dummy field values for "bike_condition_id", "bike_wheel_size_id", "bike_style_id", "serial_number", "seat_tube_height" --- app/models/bike_csv_importer.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/bike_csv_importer.rb b/app/models/bike_csv_importer.rb index 089a36f..cac2963 100644 --- a/app/models/bike_csv_importer.rb +++ b/app/models/bike_csv_importer.rb @@ -98,7 +98,7 @@ class BikeCsvImporter end def bike_attrs(bike_hash) - %i{ shop_id bike_purpose_id value bike_brand_id bike_model_id model }.each_with_object({}) do |field, memo| + %i{ shop_id bike_purpose_id value bike_brand_id bike_model_id model bike_style_id bike_condition_id seat_tube_height bike_wheel_size_id serial_number }.each_with_object({}) do |field, memo| memo[field] = send :"bike_attr_#{ field }", bike_hash end end @@ -148,6 +148,26 @@ class BikeCsvImporter model unless model =~ /unknown/i end + def bike_attr_bike_style_id(_) + @bike_style_other_cache ||= BikeStyle.find_by_style('OTHER').id + end + + def bike_attr_bike_condition_id(_) + @bike_condition_undertermined_cache ||= BikeCondition.find_by_condition('UNDETERMINED').id + end + + def bike_attr_seat_tube_height(_) + 0 + end + + def bike_attr_bike_wheel_size_id(_) + @bike_condition_wheel_size_undertermined_cache ||= BikeWheelSize.find_by_description('UNDETERMINED').id + end + + def bike_attr_serial_number(_) + 'UNDETERMINED' + end + def clean_value(value) value_or_nil strip_value(value) end