add creature and base rp_world
This commit is contained in:
22
app/workers/wow_creature_families_worker.rb
Normal file
22
app/workers/wow_creature_families_worker.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WowCreatureFamiliesWorker < WowSidekiqWorker
|
||||
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::CreatureFamily.all
|
||||
|
||||
return unless result.status_code == 200
|
||||
|
||||
result.creature_families.each do |creature_family|
|
||||
wow_creature_family = WowCreatureFamily.find_or_initialize_by(creature_family_id: creature_family.id)
|
||||
|
||||
# Localisation data
|
||||
locales.each do |locale|
|
||||
Mobility.with_locale(locale[0]) { wow_creature_family.name = creature_family.name[locale[1]] }
|
||||
end
|
||||
|
||||
wow_creature_family.save
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user