retroactively enqueue outfit images

This commit is contained in:
Emi Matchu 2012-07-31 10:20:37 -04:00
parent 54ca5881fe
commit 05acae3cb8
2 changed files with 18 additions and 0 deletions

View file

@ -4,5 +4,12 @@ class OutfitImageUpdate
def self.perform(id) def self.perform(id)
Outfit.find(id).write_image! Outfit.find(id).write_image!
end end
# Represents an outfit image update for an outfit that existed before this
# feature was built. Its queue has a lower priority, so new outfits will
# be updated before retroactively converted outfits.
class Retroactive < OutfitImageUpdate
@queue = :retroactive_outfit_image_updates
end
end end

11
lib/tasks/outfits.rake Normal file
View file

@ -0,0 +1,11 @@
namespace :outfits do
desc 'Retroactively enqueue image updates for outfits saved to user accounts'
task :retroactively_enqueue => :environment do
outfits = Outfit.select([:id]).where('image IS NULL AND user_id IS NOT NULL')
puts "Enqueuing #{outfits.count} outfits"
outfits.find_each do |outfit|
Resque.enqueue(OutfitImageUpdate::Retroactive, outfit.id)
end
puts "Successfully enqueued."
end
end