Create fact for champion picked item

This commit is contained in:
Álvaro Girona Arias
2024-06-13 15:36:05 +02:00
parent 0987290dca
commit 7e30db3864
5 changed files with 156 additions and 3 deletions
@@ -2,10 +2,12 @@ defmodule LolAnalytics.Dimensions.Item.ItemRepo do
alias LolAnalytics.Dimensions.Item.ItemSchema
alias LoLAnalytics.Repo
def get_or_create(item_id) do
item = Repo.get(ItemSchema, item_id: item_id)
import Ecto.Query
case item do
def get_or_create(item_id) do
query = from i in ItemSchema, where: i.item_id == ^item_id
case Repo.one(query) do
nil ->
item_changeset = ItemSchema.changeset(%ItemSchema{}, %{item_id: item_id})
Repo.insert(item_changeset)