2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-05-26 17:46:43 +08:00
|
|
|
module Jobs
|
2019-10-02 12:01:53 +08:00
|
|
|
class CreateMissingAvatars < ::Jobs::Scheduled
|
2014-05-26 17:46:43 +08:00
|
|
|
every 1.hour
|
2015-05-07 07:00:13 +08:00
|
|
|
|
2014-05-26 17:46:43 +08:00
|
|
|
def execute(args)
|
2015-05-07 07:00:13 +08:00
|
|
|
# backfill in batches of 5000 an hour
|
|
|
|
UserAvatar.includes(:user)
|
2017-07-28 09:20:09 +08:00
|
|
|
.joins(:user)
|
|
|
|
.where(last_gravatar_download_attempt: nil)
|
|
|
|
.order("users.last_posted_at DESC")
|
|
|
|
.limit(5000)
|
|
|
|
.each do |u|
|
2016-04-14 00:30:25 +08:00
|
|
|
u.user.refresh_avatar
|
2014-05-27 18:46:17 +08:00
|
|
|
end
|
2014-05-26 17:46:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|