update character page
This commit is contained in:
@@ -27,16 +27,13 @@ class WowCharacterDetailWorker < WowSidekiqWorker
|
||||
end
|
||||
|
||||
def find_or_create_wow_guild(guild)
|
||||
WowGuild.find_by(guild_id: guild.id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
return unless (wow_realm = WowRealm.find_by(realm_id: guild.realm.id))
|
||||
wow_guild = WowGuild.find_or_initialize_by(guild_id: guild.id)
|
||||
|
||||
wow_guild = WowGuild.create(
|
||||
guild_id: guild.id,
|
||||
name: guild.name,
|
||||
wow_relam: wow_realm
|
||||
)
|
||||
WowGuildDetailWorker.perform_async(wow_guild.guild_id)
|
||||
wow_guild
|
||||
wow_guild.name = guild.name
|
||||
wow_guild.wow_realm = WowRealm.find_by(realm_id: guild.realm.id)
|
||||
|
||||
wow_guild.save
|
||||
|
||||
wow_guild.persisted? ? wow_guild : nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WowItemsWorker < WowSidekiqWorker
|
||||
def perform(item_id, batch_size)
|
||||
def perform(item_id, batch_size, keep_going_on)
|
||||
RBattlenet.authenticate(client_id: ENV['BLIZZARD_API_CLIENT_ID'], client_secret: ENV['BLIZZARD_API_CLIENT_SECRET'])
|
||||
RBattlenet.set_options(locale: 'all')
|
||||
|
||||
@@ -43,8 +43,10 @@ class WowItemsWorker < WowSidekiqWorker
|
||||
wow_item.save
|
||||
end
|
||||
|
||||
# Create a new job for the next batch
|
||||
WowItemsWorker.perform_async(result.results.last.data.id + 1, batch_size) unless result.results.count.zero?
|
||||
# Create a new job for the next batch if keep_going_on is true
|
||||
return unless keep_going_on && !result.results.count.zero?
|
||||
|
||||
WowItemsWorker.perform_async(result.results.last.data.id + 1, batch_size, keep_going_on)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user