continue to backport old code

This commit is contained in:
2021-04-24 00:24:05 +02:00
parent 5d7217f355
commit 04434760c5
72 changed files with 795 additions and 78 deletions

View File

@@ -0,0 +1,30 @@
class WowPetsWorker < 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::Pet.all
return unless result.status_code == 200
result.pets.each do |pet|
wow_pet = WowPet.where(pet_id: pet.id).first_or_initialize
# Global data
wow_pet.pet_id = pet.id
wow_pet.href = pet.key.href
# Localisation data
locales.each do |locale|
Mobility.with_locale(locale[0]) { wow_pet.name = pet.name[locale[1]] }
end
wow_pet.save
WowPetDetailWorker.perform_async(wow_pet.pet_id) if wow_pet.persisted?
end
end
end