Files
site/app/workers/wow_mounts_collection_worker.rb

19 lines
538 B
Ruby

# frozen_string_literal: true
class WowMountsCollectionWorker < WowSidekiqWorker
def perform(user_id)
return unless (user = User.find(user_id))
RBattlenet.set_options(locale: 'en_US')
result = RBattlenet::Wow::Profile::MountsCollection.find(user.token)
return unless result.status_code == 200
result.mounts.each do |mount|
next unless (local_mount = WowMount.where(mount_id: mount.mount.id).first)
UserObtainWowMount.where(user: user.id, wow_mount: local_mount.id).first_or_create
end
end
end