Browse Source

BikeCsvImporter: add "value"

master
Ilya Konanykhin 8 years ago
parent
commit
ae8b5cccd0
  1. 14
      app/models/bike_csv_importer.rb

14
app/models/bike_csv_importer.rb

@ -57,7 +57,7 @@ class BikeCsvImporter
end
# + Velocipede Number -> Bikes.shop_id
# Program -> Bikes.bike_purpose_id
# + Program -> Bikes.bike_purpose_id
#
# Gone -> If "Yes", set 'gone' to true, then create a Log entry like the following:
# id | loggable_id | loggable_type | logger_id | logger_type | context | start_date | end_date | description | log_action_id | log_action_type | created_at | updated_at
@ -66,11 +66,11 @@ class BikeCsvImporter
#
# Date In -> Create a bike log entry with start_date & end_date with same value as "Date In". Set action_id to "AQUIRED"
# Date Out -> Should be the start_date & end_date value for "Gone" column mentioned above.
# Price -> Bikes.value
# + Price -> Bikes.value
# Make -> Bikes.bike_brand_id
# Model -> Bikes.bike_model_id
# to Whom -> ignore
# Zip Code -> ignore
# + to Whom -> ignore
# + Zip Code -> ignore
# Comment -> Create a bike log entry with action_id "NOTE". The log 'description' should be the value of 'Comment'.
#
# Data at the end of the CSV seems to be missing a lot of fields. If any field is empty, the the value can be "UNDETERMINED" if applicable, or ignored. Any other dates beside "Date In/Out" can be current date.
@ -82,7 +82,7 @@ class BikeCsvImporter
end
def bike_attrs(bike_hash)
%i{ shop_id bike_purpose_id }.each_with_object({}) do |field, memo|
%i{ shop_id bike_purpose_id value }.each_with_object({}) do |field, memo|
memo[field] = send :"bike_attr_#{ field }", bike_hash
end
end
@ -111,6 +111,10 @@ class BikeCsvImporter
%w{ yes yeah y }.include? clean_value(bike_hash['gone']).try :downcase
end
def bike_attr_value(bike_hash)
clean_value(bike_hash['price']).try(:gsub, /[$]/, '').try :to_i
end
def clean_value(value)
value_or_nil strip_value(value)
end

Loading…
Cancel
Save