Files
site/app/workers/wow_mounts_worker.rb

31 lines
813 B
Ruby

class WowMountsWorker < WowSidekiqWorker
def locales
super
end
def perform
RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
RBattlenet.set_options(locale: 'all')
result = RBattlenet::Wow::Mount.all
return unless result.status_code == 200
result.mounts.each do |mount|
wow_mount = WowMount.where(mount_id: mount.id).first_or_initialize
# Global data
wow_mount.mount_id = mount.id
wow_mount.href = mount.key.href
# Localisation data
locales.each do |locale|
Mobility.with_locale(locale[0]) { wow_mount.name = mount.name[locale[1]] }
end
wow_mount.save
WowMountDetailWorker.perform_async(wow_mount.mount_id) if wow_mount.persisted?
end
end
end