```ruby
class CheckNewAchievements
  @queue = :cron

  def self.perform
    User.all.each{|u| u.earn_achievements }
  end
end
```

Fix race condition bug, when background and realtime workers tried to check achievements for same user at once
user
```ruby
class CheckNewAchievements
  @queue = :cron

  def self.perform
    User.where(User.arel_table[:achievements_fetched_at].not_eq(nil)).each{|u| u.earn_achievements }
  end
end
```
assistant