# frozen_string_literal: true class WowMountsCollectionWorker include Sidekiq::Worker def perform(user_id) # Update the WoW character list 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