Class: Jobs::CreateMissingAvatars

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/create_missing_avatars.rb

Instance Method Summary collapse

Methods inherited from Scheduled

#perform

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/scheduled/create_missing_avatars.rb', line 7

def execute(args)
  # backfill in batches of 5000 an hour
  UserAvatar
    .includes(:user)
    .joins(:user)
    .where(last_gravatar_download_attempt: nil)
    .order("users.last_posted_at DESC")
    .limit(5000)
    .each { |u| u.user.refresh_avatar }
end