add patch_number and queue_id to dim_match
Some checks failed
ci / docker (push) Failing after 3m56s
Some checks failed
ci / docker (push) Failing after 3m56s
This commit is contained in:
parent
56ba989ad8
commit
078682fd48
@ -1,11 +1,17 @@
|
||||
defmodule LolAnalytics.Dimensions.Match.MatchRepo do
|
||||
alias LolAnalytics.Dimensions.Patch.PatchRepo
|
||||
alias LolAnalytics.Dimensions.Match.MatchSchema
|
||||
alias LoLAnalytics.Repo
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
@spec get_or_create(String.t()) :: %MatchSchema{}
|
||||
def get_or_create(match_id) do
|
||||
@spec get_or_create(%{
|
||||
:match_id => String.t(),
|
||||
:queue_id => integer(),
|
||||
:patch_number => String.t()
|
||||
}) :: %MatchSchema{}
|
||||
def get_or_create(%{match_id: match_id, queue_id: queue_id, patch_number: patch_number}) do
|
||||
_patch = PatchRepo.get_or_create(patch_number)
|
||||
query = from m in MatchSchema, where: m.match_id == ^match_id
|
||||
match = Repo.one(query)
|
||||
|
||||
@ -13,6 +19,9 @@ defmodule LolAnalytics.Dimensions.Match.MatchRepo do
|
||||
nil ->
|
||||
%MatchSchema{}
|
||||
|> MatchSchema.changeset(%{
|
||||
match_id: match_id,
|
||||
patch_number: patch_number,
|
||||
queue_id: queue_id,
|
||||
fact_champion_played_game_status: 0,
|
||||
fact_champion_picked_item_status: 0,
|
||||
fact_champion_picked_summoner_spell_status: 0
|
||||
|
@ -4,6 +4,8 @@ defmodule LolAnalytics.Dimensions.Match.MatchSchema do
|
||||
|
||||
@casting_attrs [
|
||||
:match_id,
|
||||
:queue_id,
|
||||
:patch_number,
|
||||
:fact_champion_picked_item_status,
|
||||
:fact_champion_picked_summoner_spell_status,
|
||||
:fact_champion_played_game_status
|
||||
@ -11,6 +13,8 @@ defmodule LolAnalytics.Dimensions.Match.MatchSchema do
|
||||
|
||||
schema "dim_match" do
|
||||
field :match_id, :string
|
||||
field :patch_number, :string
|
||||
field :queue_id, :integer
|
||||
field :fact_champion_picked_item_status, :integer
|
||||
field :fact_champion_picked_summoner_spell_status, :integer
|
||||
field :fact_champion_played_game_status, :integer
|
||||
|
@ -31,12 +31,18 @@ defmodule LolAnalytics.Facts.ChampionPickedItem.Repo do
|
||||
:slot_number => integer()
|
||||
}) :: {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
|
||||
def insert(attrs) do
|
||||
match = MatchRepo.get_or_create(attrs.match_id)
|
||||
_champion = ChampionRepo.get_or_create(attrs.champion_id)
|
||||
_player = PlayerRepo.get_or_create(attrs.puuid)
|
||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||
_item_id = ItemRepo.get_or_create(attrs.item_id)
|
||||
|
||||
match =
|
||||
MatchRepo.get_or_create(%{
|
||||
match_id: attrs.match_id,
|
||||
patch_id: attrs.patch_id,
|
||||
queue_id: attrs.queue_id
|
||||
})
|
||||
|
||||
prev =
|
||||
from(f in Schema,
|
||||
where:
|
||||
|
@ -22,12 +22,18 @@ defmodule LolAnalytics.Facts.ChampionPickedSummonerSpell.Repo do
|
||||
:summoner_spell_id => String.t()
|
||||
}) :: any()
|
||||
def insert(attrs) do
|
||||
match = MatchRepo.get_or_create(attrs.match_id)
|
||||
_champion = ChampionRepo.get_or_create(attrs.champion_id)
|
||||
_player = PlayerRepo.get_or_create(attrs.puuid)
|
||||
_spell = SummonerSpellRepo.get_or_create(attrs.summoner_spell_id)
|
||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||
|
||||
match =
|
||||
MatchRepo.get_or_create(%{
|
||||
match_id: attrs.match_id,
|
||||
patch_id: attrs.patch_id,
|
||||
queue_id: attrs.queue_id
|
||||
})
|
||||
|
||||
prev =
|
||||
from(f in Schema,
|
||||
where:
|
||||
|
@ -10,10 +10,10 @@ defmodule LolAnalytics.Facts.ChampionPlayedGame.Repo do
|
||||
alias LoLAnalytics.Repo
|
||||
|
||||
def insert(attrs) do
|
||||
match = MatchRepo.get_or_create(attrs.match_id)
|
||||
_champion = ChampionRepo.get_or_create(attrs.champion_id)
|
||||
_player = PlayerRepo.get_or_create(attrs.puuid)
|
||||
_patch = PatchRepo.get_or_create(attrs.patch_number)
|
||||
match = MatchRepo.get_or_create(attrs.match_id)
|
||||
|
||||
prev =
|
||||
from(f in Schema,
|
||||
|
@ -0,0 +1,9 @@
|
||||
defmodule LoLAnalytics.Repo.Migrations.DimMatchQueueId do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table "dim_match" do
|
||||
add :queue_id, :integer
|
||||
end
|
||||
end
|
||||
end
|
@ -58,6 +58,12 @@ defmodule Scrapper.Processor.MatchProcessor do
|
||||
"#{decoded_match.info.gameVersion}"
|
||||
)
|
||||
|
||||
LolAnalytics.Dimensions.Match.MatchRepo.get_or_create(%{
|
||||
match_id: decoded_match.metadata.matchId,
|
||||
patch_number: decoded_match.info.gameVersion,
|
||||
queue_id: 420
|
||||
})
|
||||
|
||||
_queue_id ->
|
||||
Storage.MatchStorage.S3MatchStorage.store_match(match_id, raw_match, "matches")
|
||||
end
|
||||
@ -79,7 +85,7 @@ defmodule Scrapper.Processor.MatchProcessor do
|
||||
|> Enum.shuffle()
|
||||
|> Enum.take(2)
|
||||
|> Enum.each(fn participant_puuid ->
|
||||
Scrapper.Queue.PlayerQueue.queue_puuid(participant_puuid)
|
||||
Scrapper.Queue.PlayerQueue.enqueue_puuid(participant_puuid)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -52,7 +52,7 @@ defmodule Scrapper.Processor.PlayerProcessor do
|
||||
{
|
||||
matches
|
||||
|> Enum.each(fn match_id ->
|
||||
Scrapper.Queue.MatchQueue.queue_match(match_id)
|
||||
Scrapper.Queue.MatchQueue.enqueue_match(match_id)
|
||||
end)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user