continue to backport old code
This commit is contained in:
33
app/workers/wow_mount_detail_worker.rb
Normal file
33
app/workers/wow_mount_detail_worker.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
class WowMountDetailWorker < WowSidekiqWorker
|
||||
def locales
|
||||
super
|
||||
end
|
||||
|
||||
def perform(mount_id)
|
||||
return unless (mount = WowMount.where(mount_id: mount_id).first)
|
||||
|
||||
RBattlenet.set_options(locale: 'all')
|
||||
result = RBattlenet::Wow::Mount.find(mount_id)
|
||||
|
||||
return unless result.status_code == 200
|
||||
|
||||
mount.faction = result.faction.type if result.faction
|
||||
|
||||
# Localisation data
|
||||
locales.each do |locale|
|
||||
Mobility.with_locale(locale[0]) do
|
||||
mount.translated_faction = result.faction.name[locale[1]] if result.faction
|
||||
mount.description = result.description[locale[1]]
|
||||
end
|
||||
end
|
||||
|
||||
if result.creature_displays.first
|
||||
mount.creature_display_id = result.creature_displays.first.id
|
||||
|
||||
media = RBattlenet::Wow::CreatureMedia.find(result.creature_displays.first.id)
|
||||
mount.asset_zoom = media.assets.find { |asset| asset['key'] == 'zoom' }.value || nil
|
||||
end
|
||||
|
||||
mount.save
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user