# 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
classBikeCsvImporter
includeBikeCsvImporter::Cache
includeBikeCsvImporter::Cache
includeBikeCsvImporter::Cleaner
includeBikeCsvImporter::Cleaner
includeBikeCsvImporter::BikeAttrs
includeBikeCsvImporter::BikeAttrs
attr_reader:file,:dry_run
attr_reader:file
definitialize(file,dry_run)
definitialize(file)
@file=file
@file=file
@dry_run=!!dry_run
end
end
defrun
defrun(dry_run)
result={imported:{},skipped:{}}
result={imported:{},skipped:{}}
fetchdo|bike_hash|
fetchdo|bike_hash|
bike=import_bikebike_hash
bike=new_bikebike_hash
check_method=dry_run?:valid?::persisted?
check_method=dry_run?:valid?::save
ifbike.trycheck_method
ifbike.trycheck_method
result[:imported][bike.shop_id]=bike.inspect
result[:imported][bike.shop_id]=bike.inspect
else
else
@ -65,18 +73,7 @@ class BikeCsvImporter
@header.zip(row).to_h
@header.zip(row).to_h
end
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'.