continue to backport old code
This commit is contained in:
44
app/workers/wow_pet_detail_worker.rb
Normal file
44
app/workers/wow_pet_detail_worker.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
class WowPetDetailWorker < WowSidekiqWorker
|
||||
def locales
|
||||
super
|
||||
end
|
||||
|
||||
def perform(pet_id)
|
||||
|
||||
return unless (pet = WowPet.where(pet_id: pet_id).first)
|
||||
|
||||
RBattlenet.set_options(locale: 'all')
|
||||
result = RBattlenet::Wow::Pet.find(pet_id)
|
||||
|
||||
return unless result.status_code == 200
|
||||
|
||||
pet.is_capturable = result.is_capturable
|
||||
pet.is_battlepet = result.is_battlepet
|
||||
pet.is_alliance_only = result.is_alliance_only
|
||||
pet.is_horde_only = result.is_horde_only
|
||||
pet.is_capturable = result.is_capturable
|
||||
pet.is_random_creature_display = result.is_random_creature_display
|
||||
pet.icon = result.icon
|
||||
pet.creature_id = result.creature.id
|
||||
pet.battle_pet_type = result.battle_pet_type.type
|
||||
pet.battle_pet_type_id = result.battle_pet_type.id
|
||||
|
||||
# Localisation data
|
||||
locales.each do |locale|
|
||||
Mobility.with_locale(locale[0]) do
|
||||
pet.translated_battle_pet_type = result.battle_pet_type.name[locale[1]]
|
||||
pet.description = result.description[locale[1]]
|
||||
end
|
||||
end
|
||||
|
||||
if result.abilities
|
||||
result.abilities.each do |ability|
|
||||
next unless (local_ability = WowPetAbility.where(ability_id: ability.ability.id).first)
|
||||
|
||||
LearnedWowPetAbility.where(wow_pet: pet.id, wow_pet_ability: local_ability.id).first_or_create
|
||||
end
|
||||
end
|
||||
|
||||
pet.save
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user