update db: make puuid unique, add status column
This commit is contained in:
@@ -18,9 +18,12 @@ defmodule LolAnalytics.Player.PlayerRepo do
|
||||
LoLAnalytics.Repo.one(query)
|
||||
end
|
||||
|
||||
def insert_player(puuid) do
|
||||
@spec insert_player(String.t(), keyword()) :: %PlayerSchema{}
|
||||
def insert_player(puuid, attrs \\ %{}) do
|
||||
attrs = Map.merge(%{puuid: puuid, region: "EUW", status: "queued"}, attrs)
|
||||
|
||||
%PlayerSchema{}
|
||||
|> PlayerSchema.changeset(%{puuid: puuid, region: "EUW"})
|
||||
|> PlayerSchema.changeset(attrs)
|
||||
|> LoLAnalytics.Repo.insert()
|
||||
end
|
||||
|
||||
|
||||
@@ -18,5 +18,6 @@ defmodule LolAnalytics.Player.PlayerSchema do
|
||||
player
|
||||
|> cast(params, [:puuid, :region, :last_processed_at])
|
||||
|> validate_required([:puuid, :region, :last_processed_at])
|
||||
|> unique_constraint(:puuid)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user