initial rebuild from v1

This commit is contained in:
2021-04-22 22:31:23 +02:00
commit cc8cf4954d
152 changed files with 11559 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
class WowRealmsWorker
include Sidekiq::Worker
def perform
locales = [
['en-us', 'en_US'],
['es-mx', 'es_MX'],
['pt-br', 'pt_BR'],
['de-de', 'de_DE'],
['en-gb', 'en_GB'],
['es-es', 'es_ES'],
['fr-fr', 'fr_FR'],
['it', 'it_IT'],
['ru-ru', 'ru_RU'],
['ko', 'ko_KR'],
['zh-tw', 'zh_TW'],
['zh-cn', 'zh_CN']
]
RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
RBattlenet.set_options(locale: 'all')
result = RBattlenet::Wow::Realm.all
return unless result.status_code == 200
result.realms.each do |realm|
wow_realm = WowRealm.where(realm_id: realm.id).first_or_initialize
wow_realm.realm_id = realm.id
wow_realm.slug = realm.slug
wow_realm.href = realm.key.href
# Localisation data
locales.each do |locale|
Mobility.with_locale(locale[0]) { wow_realm.name = realm.name[locale[1]] }
end
wow_realm.save
WowRealmDetailWorker.perform_async(wow_realm.realm_id) if wow_realm.persisted?
end
end
end