Created
June 11, 2012 18:41
-
-
Save amcclosky/2911835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :history => :environment do | |
item = Item.find(21064127) | |
start_date = item.updated.to_date - 90 | |
item.item_logs.delete_all | |
90.times do |i| | |
if i % 7 == 0 | |
item_log = ItemLog.new | |
item_log.company_id = item.company_id | |
item_log.item_id = item.id | |
item_log.beforePrice = item.price | |
item_log.afterprice = item.price | |
item_log.created = start_date + i | |
item_log.save | |
end | |
end | |
item.competing_items.each do |competing_item| | |
competing_item.item_logs.delete_all | |
90.times do |i| | |
if i % 7 == 0 | |
item_log = ItemLog.new | |
item_log.company_id = competing_item.company_id | |
item_log.item_id = competing_item.id | |
item_log.beforePrice = competing_item.price | |
item_log.afterprice = competing_item.price | |
item_log.created = start_date + i | |
item_log.save | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment