# 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 Out -> Should be the start_date & end_date value for "Gone" column mentioned above.
# Comment -> Create a bike log entry with action_id "NOTE". The log 'description' should be the value of 'Comment'.
classBikeCsvImporter
includeBikeCsvImporter::Cache
includeBikeCsvImporter::Cleaner
includeBikeCsvImporter::BikeAttrs
attr_reader:file,:dry_run
attr_reader:file
definitialize(file,dry_run)
@file=file
@dry_run=!!dry_run
definitialize(file)
@file=file
end
defrun
defrun(dry_run)
result={imported:{},skipped:{}}
fetchdo|bike_hash|
bike=import_bikebike_hash
check_method=dry_run?:valid?::persisted?
bike=new_bikebike_hash
check_method=dry_run?:valid?::save
ifbike.trycheck_method
result[:imported][bike.shop_id]=bike.inspect
else
@ -65,18 +73,7 @@ class BikeCsvImporter
@header.zip(row).to_h
end
# Gone -> If "Yes", set 'gone' to true, then create a Log entry like the following:
# 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 Out -> Should be the start_date & end_date value for "Gone" column mentioned above.
# Comment -> Create a bike log entry with action_id "NOTE". The log 'description' should be the value of 'Comment'.