mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
slow down the back fill process a bit
This commit is contained in:
parent
f733d5532f
commit
6e0f54ba9a
@ -2,14 +2,17 @@ module Jobs
|
|||||||
class CreateMissingAvatars < Jobs::Scheduled
|
class CreateMissingAvatars < Jobs::Scheduled
|
||||||
every 1.hour
|
every 1.hour
|
||||||
def execute(args)
|
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|
|
UserAvatar.where(system_upload_id: nil).find_each do |a|
|
||||||
a.update_system_avatar!
|
a.update_system_avatar!
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
9
spec/jobs/create_missing_avatars_spec.rb
Normal file
9
spec/jobs/create_missing_avatars_spec.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user