This commit is contained in:
parent
e364b20b1b
commit
8ed22bebf0
@ -13,6 +13,6 @@ defmodule LolAnalytics.Dimensions.Item.ItemSchema do
|
|||||||
def changeset(item = %__MODULE__{}, attrs \\ %{}) do
|
def changeset(item = %__MODULE__{}, attrs \\ %{}) do
|
||||||
item
|
item
|
||||||
|> cast(attrs, @args)
|
|> cast(attrs, @args)
|
||||||
|> validate_required(@args)
|
|> validate_required([:item_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ defmodule LolAnalytics.Dimensions.Match.MatchRepo do
|
|||||||
fact_champion_picked_item_status: 0,
|
fact_champion_picked_item_status: 0,
|
||||||
fact_champion_picked_summoner_spell_status: 0
|
fact_champion_picked_summoner_spell_status: 0
|
||||||
})
|
})
|
||||||
|> Repo.insert()
|
|> Repo.insert!()
|
||||||
|
|
||||||
match ->
|
match ->
|
||||||
match
|
match
|
||||||
@ -54,7 +54,7 @@ defmodule LolAnalytics.Dimensions.Match.MatchRepo do
|
|||||||
|
|
||||||
match
|
match
|
||||||
|> MatchSchema.changeset(mapped_attrs)
|
|> MatchSchema.changeset(mapped_attrs)
|
||||||
|> Repo.update()
|
|> Repo.update!()
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_matches() do
|
def list_matches() do
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
defmodule LolAnalytics.Facts.ChampionPickedItem.FactProcessor do
|
defmodule LolAnalytics.Facts.ChampionPickedItem.FactProcessor do
|
||||||
|
alias LolAnalytics.Dimensions.Match.MatchRepo
|
||||||
alias LolAnalytics.Facts.ChampionPickedItem.Repo
|
alias LolAnalytics.Facts.ChampionPickedItem.Repo
|
||||||
require Logger
|
require Logger
|
||||||
@behaviour LolAnalytics.Facts.FactBehaviour
|
@behaviour LolAnalytics.Facts.FactBehaviour
|
||||||
@ -24,6 +25,13 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.FactProcessor do
|
|||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
match =
|
||||||
|
MatchRepo.get_or_create(%{
|
||||||
|
match_id: decoded_match.metadata.matchId,
|
||||||
|
patch_number: decoded_match.info.gameVersion,
|
||||||
|
queue_id: decoded_match.info.queueId
|
||||||
|
})
|
||||||
|
|
||||||
Logger.info("Processing ChampionPickedItem for match #{decoded_match.metadata.matchId}")
|
Logger.info("Processing ChampionPickedItem for match #{decoded_match.metadata.matchId}")
|
||||||
|
|
||||||
participants
|
participants
|
||||||
@ -49,6 +57,8 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.FactProcessor do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
MatchRepo.update(match, %{fact_champion_picked_item_status: :processed})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_game_version(game_data) do
|
defp extract_game_version(game_data) do
|
||||||
|
@ -36,7 +36,7 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.Repo do
|
|||||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||||
_item_id = ItemRepo.get_or_create(attrs.item_id)
|
_item_id = ItemRepo.get_or_create(attrs.item_id)
|
||||||
|
|
||||||
match =
|
_match =
|
||||||
MatchRepo.get_or_create(%{
|
MatchRepo.get_or_create(%{
|
||||||
match_id: attrs.match_id,
|
match_id: attrs.match_id,
|
||||||
patch_number: attrs.patch_number,
|
patch_number: attrs.patch_number,
|
||||||
@ -55,8 +55,6 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.Repo do
|
|||||||
|
|
||||||
Schema.changeset(prev || %Schema{}, attrs)
|
Schema.changeset(prev || %Schema{}, attrs)
|
||||||
|> Repo.insert_or_update()
|
|> Repo.insert_or_update()
|
||||||
|
|
||||||
MatchRepo.update(match, %{fact_champion_picked_item: :processed})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_champion_picked_items(String.t(), String.t(), String.t()) :: list()
|
@spec get_champion_picked_items(String.t(), String.t(), String.t()) :: list()
|
||||||
|
@ -3,6 +3,7 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.FactProcessor do
|
|||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
alias LolAnalytics.Dimensions.Match.MatchRepo
|
||||||
alias LolAnalytics.Facts.ChampionPickedSummonerSpell
|
alias LolAnalytics.Facts.ChampionPickedSummonerSpell
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
@ -23,6 +24,13 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.FactProcessor do
|
|||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
match =
|
||||||
|
MatchRepo.get_or_create(%{
|
||||||
|
match_id: decoded_match.metadata.matchId,
|
||||||
|
patch_number: decoded_match.info.gameVersion,
|
||||||
|
queue_id: decoded_match.info.queueId
|
||||||
|
})
|
||||||
|
|
||||||
Logger.info("Processing ChampionPickedSummoner for match #{decoded_match.metadata.matchId}")
|
Logger.info("Processing ChampionPickedSummoner for match #{decoded_match.metadata.matchId}")
|
||||||
|
|
||||||
participants
|
participants
|
||||||
@ -56,6 +64,8 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.FactProcessor do
|
|||||||
ChampionPickedSummonerSpell.Repo.insert(attrs_spell_2)
|
ChampionPickedSummonerSpell.Repo.insert(attrs_spell_2)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
MatchRepo.update(match, %{fact_champion_picked_summoner_spell_status: :processed})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_game_version(game_data) do
|
defp extract_game_version(game_data) do
|
||||||
|
@ -27,7 +27,7 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.Repo do
|
|||||||
_spell = SummonerSpellRepo.get_or_create(attrs.summoner_spell_id)
|
_spell = SummonerSpellRepo.get_or_create(attrs.summoner_spell_id)
|
||||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||||
|
|
||||||
match =
|
_match =
|
||||||
MatchRepo.get_or_create(%{
|
MatchRepo.get_or_create(%{
|
||||||
match_id: attrs.match_id,
|
match_id: attrs.match_id,
|
||||||
patch_number: attrs.patch_number,
|
patch_number: attrs.patch_number,
|
||||||
@ -46,8 +46,6 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.Repo do
|
|||||||
|
|
||||||
Schema.changeset(prev || %Schema{}, attrs)
|
Schema.changeset(prev || %Schema{}, attrs)
|
||||||
|> Repo.insert_or_update()
|
|> Repo.insert_or_update()
|
||||||
|
|
||||||
MatchRepo.update(match, %{fact_champion_picked_summoner_spell: :processed})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_champion_picked_summoners(String.t(), String.t(), String.t()) :: list()
|
@spec get_champion_picked_summoners(String.t(), String.t(), String.t()) :: list()
|
||||||
|
@ -13,7 +13,8 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.Repo do
|
|||||||
_champion = ChampionRepo.get_or_create(attrs.champion_id)
|
_champion = ChampionRepo.get_or_create(attrs.champion_id)
|
||||||
_player = PlayerRepo.get_or_create(attrs.puuid)
|
_player = PlayerRepo.get_or_create(attrs.puuid)
|
||||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||||
match =
|
|
||||||
|
_match =
|
||||||
MatchRepo.get_or_create(%{
|
MatchRepo.get_or_create(%{
|
||||||
match_id: attrs.match_id,
|
match_id: attrs.match_id,
|
||||||
patch_number: attrs.patch_number,
|
patch_number: attrs.patch_number,
|
||||||
@ -31,7 +32,6 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.Repo do
|
|||||||
changeset = Schema.changeset(prev || %Schema{}, attrs)
|
changeset = Schema.changeset(prev || %Schema{}, attrs)
|
||||||
|
|
||||||
Repo.insert_or_update(changeset)
|
Repo.insert_or_update(changeset)
|
||||||
MatchRepo.update(match, %{fact_champion_played_game: :processed})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_played_matches() do
|
def list_played_matches() do
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
defmodule LolAnalytics.Facts.ChampionPlayedGame.FactProcessor do
|
defmodule LolAnalytics.Facts.ChampionPlayedGame.FactProcessor do
|
||||||
|
alias LolAnalytics.Dimensions.Match.MatchRepo
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@behaviour LolAnalytics.Facts.FactBehaviour
|
@behaviour LolAnalytics.Facts.FactBehaviour
|
||||||
@ -21,6 +22,13 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.FactProcessor do
|
|||||||
participants = decoded_match.info.participants
|
participants = decoded_match.info.participants
|
||||||
version = extract_game_version(decoded_match)
|
version = extract_game_version(decoded_match)
|
||||||
|
|
||||||
|
match =
|
||||||
|
MatchRepo.get_or_create(%{
|
||||||
|
match_id: decoded_match.metadata.matchId,
|
||||||
|
patch_number: decoded_match.info.gameVersion,
|
||||||
|
queue_id: decoded_match.info.queueId
|
||||||
|
})
|
||||||
|
|
||||||
Logger.info("Processing ChampionPlayedMatch for #{decoded_match.metadata.matchId}")
|
Logger.info("Processing ChampionPlayedMatch for #{decoded_match.metadata.matchId}")
|
||||||
|
|
||||||
participants
|
participants
|
||||||
@ -40,6 +48,8 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.FactProcessor do
|
|||||||
LolAnalytics.Facts.ChampionPlayedGame.Repo.insert(attrs)
|
LolAnalytics.Facts.ChampionPlayedGame.Repo.insert(attrs)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
MatchRepo.update(match, %{fact_champion_played_game_status: :processed})
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_game_version(game_data) do
|
defp extract_game_version(game_data) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user