Skip to content

Instantly share code, notes, and snippets.

@llopez
Created June 23, 2014 21:42
Show Gist options
  • Save llopez/1f557eb691537bdea8e7 to your computer and use it in GitHub Desktop.
Save llopez/1f557eb691537bdea8e7 to your computer and use it in GitHub Desktop.
Rake task for migrating to panda/s3
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
@desaperados
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment