This commit is contained in:
parent
4823e68700
commit
bd8148f3e2
@ -1,42 +0,0 @@
|
||||
defmodule LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props.SummonerSpell do
|
||||
defstruct [:id, :name, :win_rate, :wins, :total_games, :image]
|
||||
|
||||
@type t :: %{
|
||||
id: integer(),
|
||||
win_rate: float(),
|
||||
wins: integer(),
|
||||
total_games: integer(),
|
||||
image: String.t(),
|
||||
name: String.t()
|
||||
}
|
||||
end
|
||||
|
||||
defmodule LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props do
|
||||
alias LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props.SummonerSpell
|
||||
|
||||
defstruct spell: %SummonerSpell{}
|
||||
|
||||
@type t :: %{spell: SummonerSpell.t()}
|
||||
end
|
||||
|
||||
defmodule LolAnalyticsWeb.ChampionComponents.SummonerSpell do
|
||||
alias LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props
|
||||
use Phoenix.Component
|
||||
|
||||
attr :spells, Props, default: %Props{}
|
||||
|
||||
def summoner_spells(assigns) do
|
||||
~H"""
|
||||
<div class="flex flex-wrap flex-wrap gap-4">
|
||||
<%= for spell <- assigns.spells.summoner_spells do %>
|
||||
<div clas="flex flex-col gap-1">
|
||||
<img src={spell.spell.image} />
|
||||
<p><%= spell.spell.name %></p>
|
||||
<p><%= spell.spell.win_rate %>%</p>
|
||||
<p><%= spell.spell.wins %>/<%= spell.spell.total_games %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
defmodule LolAnalyticsWeb.ChampionComponents.SummonerSpells do
|
||||
alias LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props
|
||||
use Phoenix.Component
|
||||
|
||||
def summoner_spells(assigns) do
|
||||
~H"""
|
||||
<div class="flex flex-wrap flex-wrap gap-4">
|
||||
<%= for spell <- assigns.spells.summoner_spells do %>
|
||||
<div clas="flex flex-col gap-1">
|
||||
<img src={spell.image} />
|
||||
<p><%= spell.name %></p>
|
||||
<p><%= spell.win_rate %>%</p>
|
||||
<p><%= spell.wins %>/<%= spell.total_games %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
defmodule LoLAnalyticsWeb.ChampionLive.Show do
|
||||
use LoLAnalyticsWeb, :live_view
|
||||
|
||||
import LolAnalyticsWeb.ChampionComponents.SummonerSpell
|
||||
import LolAnalyticsWeb.ChampionComponents.SummonerSpells
|
||||
import LolAnalyticsWeb.ChampionComponents.ChampionAvatar
|
||||
|
||||
alias LolAnalyticsWeb.ChampionComponents.SummonerSpells.ShowMapper
|
||||
@ -26,6 +26,10 @@ defmodule LoLAnalyticsWeb.ChampionLive.Show do
|
||||
LolAnalytics.Facts.ChampionPickedSummonerSpell.Repo.get_champion_picked_summoners(champion_id)
|
||||
end
|
||||
|
||||
defp load_items(champion_id) do
|
||||
LolAnalytics.Facts.ChampionPickedItem.Repo.get_champion_picked_items(champion_id)
|
||||
end
|
||||
|
||||
defp load_champion_info(champion_id) do
|
||||
champion = LolAnalytics.Dimensions.Champion.ChampionRepo.get_or_create(champion_id)
|
||||
|
||||
|
@ -13,21 +13,22 @@ defmodule LolAnalyticsWeb.ChampionComponents.SummonerSpells.ShowMapper do
|
||||
def map_spells(items) do
|
||||
items
|
||||
|> Enum.map(&map_spell/1)
|
||||
|> Enum.sort(&(&1.spell.total_games > &2.spell.total_games))
|
||||
|> Enum.sort(&(&1.total_games > &2.total_games))
|
||||
end
|
||||
|
||||
def map_spell(spell) do
|
||||
image = spell.metadata["image"]["full"]
|
||||
|
||||
%LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props{
|
||||
spell: %LolAnalyticsWeb.ChampionComponents.SummonerSpells.Props.SummonerSpell{
|
||||
id: spell.id,
|
||||
%{
|
||||
id: spell["id"],
|
||||
win_rate: :erlang.float_to_binary(spell.win_rate, decimals: 2),
|
||||
total_games: spell.total_games,
|
||||
image: "https://ddragon.leagueoflegends.com/cdn/14.11.1/img/spell/#{image}",
|
||||
name: spell.metadata["name"],
|
||||
wins: spell.wins
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def map_item(item) do
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user