Created
June 23, 2014 21:42
-
-
Save llopez/1f557eb691537bdea8e7 to your computer and use it in GitHub Desktop.
Rake task for migrating to panda/s3
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
namespace :panda do | |
desc "Migrate to panda/s3" | |
task :migrate do | |
FileAttachment.all.select(&:video?).each{ |fa| | |
VideoAttachmentWorker.perform_async({ | |
title: fa.title, | |
description: fa.description, | |
recordable_id: fa.attachable_id, | |
recordable_type: fa.attachable_type, | |
source_url: fa.data.url | |
}) | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I usually prefer find_each to batch operations like this rather than all.
Looks fairly simple in the end:)
So I guess this is going to complete relatively quickly on our end, but create a LOT of work for panda, which is how we want it. The logic on the recordable model to determine whether we can serve the new video is going to be important.