slow down the back fill process a bit

This commit is contained in:
Sam 2014-05-27 20:46:17 +10:00
parent f733d5532f
commit 6e0f54ba9a
2 changed files with 17 additions and 5 deletions

View File

@ -2,14 +2,17 @@ module Jobs
class CreateMissingAvatars < Jobs::Scheduled
every 1.hour
def execute(args)
User.where(uploaded_avatar_id: nil).find_each do |u|
u.refresh_avatar
u.save
end
UserAvatar.where(system_upload_id: nil).find_each do |a|
a.update_system_avatar!
end
# backfill in batches 1000 an hour
User.where(uploaded_avatar_id: nil)
.order("last_posted_at desc")
.limit(1000).find_each do |u|
u.refresh_avatar
u.save
end
end
end
end

View File

@ -0,0 +1,9 @@
require 'spec_helper'
require_dependency 'jobs/scheduled/create_missing_avatars'
describe Jobs::CreateMissingAvatars do
it "runs correctly without crashing" do
Jobs::CreateMissingAvatars.new.execute(nil)
end
end