mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 08:43:23 -05:00
BikeCsvImporter: add "value"
This commit is contained in:
parent
c79ec57684
commit
ae8b5cccd0
@ -57,20 +57,20 @@ class BikeCsvImporter
|
|||||||
end
|
end
|
||||||
|
|
||||||
# + Velocipede Number -> Bikes.shop_id
|
# + 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:
|
# 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
|
# 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
|
||||||
# 18 | 1 | Bike | 4 | User | | 2017-02-03 23:27:00 | 2017-02-03 23:27:00 | Gone | 5 | ActsAsLoggable::BikeAction | 2017-02-03 23:27:36.8387 | 2017-02-03 23:27:36.8387
|
# 18 | 1 | Bike | 4 | User | | 2017-02-03 23:27:00 | 2017-02-03 23:27:00 | Gone | 5 | ActsAsLoggable::BikeAction | 2017-02-03 23:27:36.8387 | 2017-02-03 23:27:36.8387
|
||||||
# See https://github.com/spacemunkay/BikeShed/blob/master/app/components/bike_logs.rb#L12-L18 for example. Use user_id 1 for current_user_id (1 should be the admin ID I think). Use "Date Out" column for start_date & end_date. Set action_id to "COMPLETED".
|
# See https://github.com/spacemunkay/BikeShed/blob/master/app/components/bike_logs.rb#L12-L18 for example. Use user_id 1 for current_user_id (1 should be the admin ID I think). Use "Date Out" column for start_date & end_date. Set action_id to "COMPLETED".
|
||||||
#
|
#
|
||||||
# Date In -> Create a bike log entry with start_date & end_date with same value as "Date In". Set action_id to "AQUIRED"
|
# 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.
|
# 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
|
# Make -> Bikes.bike_brand_id
|
||||||
# Model -> Bikes.bike_model_id
|
# Model -> Bikes.bike_model_id
|
||||||
# to Whom -> ignore
|
# + to Whom -> ignore
|
||||||
# Zip Code -> ignore
|
# + Zip Code -> ignore
|
||||||
# Comment -> Create a bike log entry with action_id "NOTE". The log 'description' should be the value of 'Comment'.
|
# 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.
|
# 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
|
end
|
||||||
|
|
||||||
def bike_attrs(bike_hash)
|
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
|
memo[field] = send :"bike_attr_#{ field }", bike_hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -111,6 +111,10 @@ class BikeCsvImporter
|
|||||||
%w{ yes yeah y }.include? clean_value(bike_hash['gone']).try :downcase
|
%w{ yes yeah y }.include? clean_value(bike_hash['gone']).try :downcase
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bike_attr_value(bike_hash)
|
||||||
|
clean_value(bike_hash['price']).try(:gsub, /[$]/, '').try :to_i
|
||||||
|
end
|
||||||
|
|
||||||
def clean_value(value)
|
def clean_value(value)
|
||||||
value_or_nil strip_value(value)
|
value_or_nil strip_value(value)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user