update character page

This commit is contained in:
2021-05-30 13:58:36 +02:00
parent f4f3862c74
commit 6ed5be10df
15 changed files with 26 additions and 15 deletions

View File

@@ -5,7 +5,7 @@
<tr>
<th scope="col"></th>
<th scope="col"><%= t('wow_characters.character_list.name') %></th>
<th scope="col"><%= t('wow_characters.character_list.gender') %></th>
<th scope="col"><%= t('wow_characters.character_list.guild') %></th>
<th scope="col"><%= t('wow_characters.character_list.realm') %></th>
<th scope="col"><%= t('wow_characters.character_list.race') %></th>
<th scope="col"><%= t('wow_characters.character_list.class') %></th>
@@ -20,7 +20,7 @@
<img class="rounded-circle border border-white" src=<%= character.wow_character_medium.avatar %> alt="avatar">
<% end %></td>
<td><%= link_to character.name, character %></td>
<td><%= character.translated_gender %></td>
<td><%= character.wow_guild&.name %></td>
<td><%= character.wow_realm.name %></td>
<td><%= gender_race_name(character.gender, character.wow_race) %></td>
<td><%= gender_class_name(character.gender, character.wow_class) %></td>

View File

@@ -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

View File

@@ -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