wip analytics tables
Some checks are pending
ci / docker (push) Waiting to run

This commit is contained in:
Álvaro 2024-05-29 15:34:27 +02:00
parent 5ce7ce0542
commit 6053cfcdac
4 changed files with 66 additions and 2 deletions

View File

@ -13,8 +13,8 @@ defmodule LolAnalytics.Analyzer.ChampionAnalyzer do
@doc """
iex> LolAnalytics.Analyzer.ChampionAnalyzer.analyze(:url, "http://localhost:9000/ranked/14.9.580.2108/EUW1_6923309745.json")
"""
@spec analyze(any(), any()) :: none()
@impl true
@spec analyze(atom(), String.t()) :: :ok
def analyze(:url, path) do
data = HTTPoison.get!(path)
analyze(:data, data.body)
@ -22,7 +22,6 @@ defmodule LolAnalytics.Analyzer.ChampionAnalyzer do
end
@impl true
@spec analyze(atom(), any()) :: list(LoLAPI.Model.Participant.t())
def analyze(:data, data) do
decoded_match = Poison.decode!(data, as: %LoLAPI.Model.MatchResponse{})
participants = decoded_match.info.participants

View File

@ -0,0 +1,3 @@
defmodule LolAnalytics.Facts.ChampionPlayedGame.ChampionPlayedGameRepo do
end

View File

@ -0,0 +1,11 @@
defmodule LolAnalytics.Facts.ChampionPlayedGame.ChampionPlayedGameSchema do
use Ecto.Schema
schema "fact_champion_played_game" do
field :champion_id, :integer
field :match_id, :integer
field :is_win, :boolean
field :game_length_seconds, :integer
field :queue_id, :integer
end
end

View File

@ -0,0 +1,51 @@
defmodule LoLAnalytics.Repo.Migrations.AnalyticsTables do
use Ecto.Migration
def change do
create table("dom_champion") do
add :champion_id, :integer, primary_key: true
timestamps()
end
create table("dom_match") do
add :match_id, :integer, primary_key: true
timestamps()
end
create index("dom_match", [:match_id], unique: true)
create table("dom_patch") do
add :patch_number, :string, primary_key: true
timestamps()
end
create index("dom_patch", [:patch_number], unique: true)
create table("dom_item") do
add :item_id, :integer, primary_key: true
timestamps()
end
create index("dom_item", [:item_id], unique: true)
create table("dom_summoner_spell") do
add :spell_id, :integer, primary_key: true
timestamps()
end
create index("dom_summoner_spell", [:spell_id], unique: true)
create table("fact_champion_played_game") do
add :champion_id, references("dom_champion", with: [champion_id: :champion_id]),
primary_key: true
add :match_id, references("dom_match", with: [match_id: :match_id])
add :is_win, :boolean
add :game_length_seconds, :integer
add :queue_id, :integer
timestamps()
end
create index("fact_champion_played_game", [:id, :champion_id, :queue_id])
end
end