diff --git a/lib/teiserver.ex b/lib/teiserver.ex index 01e387513..5834c9087 100644 --- a/lib/teiserver.ex +++ b/lib/teiserver.ex @@ -248,6 +248,10 @@ defmodule Teiserver do @spec get_user_by_name(String.t()) :: User.t() | nil defdelegate get_user_by_name(name), to: UserLib + @doc section: :user + @spec get_user_by_email(String.t()) :: User.t() | nil + defdelegate get_user_by_email(email), to: UserLib + ### Connections # Client @doc section: :client diff --git a/lib/teiserver/account/queries/user_queries.ex b/lib/teiserver/account/queries/user_queries.ex index fb3635104..6172016b1 100644 --- a/lib/teiserver/account/queries/user_queries.ex +++ b/lib/teiserver/account/queries/user_queries.ex @@ -265,4 +265,11 @@ defmodule Teiserver.Account.UserQueries do preload: [extra_data: extra_datas] ) end + + def _preload(query, :smurf_of) do + from(user in query, + left_join: smurf_ofs in assoc(user, :smurf_of), + preload: [smurf_of: smurf_ofs] + ) + end end diff --git a/lib/teiserver/game/schemas/match.ex b/lib/teiserver/game/schemas/match.ex index 1e329a665..cd7cd96bd 100644 --- a/lib/teiserver/game/schemas/match.ex +++ b/lib/teiserver/game/schemas/match.ex @@ -34,11 +34,12 @@ defmodule Teiserver.Game.Match do field(:game_name, :string) field(:game_version, :string) + field(:team_count, :integer) + field(:team_size, :integer) + field(:player_count, :integer) # Outcome field(:winning_team, :integer) - field(:team_count, :integer) - field(:team_size, :integer) field(:processed?, :boolean, default: false) field(:ended_normally?, :boolean) @@ -47,8 +48,9 @@ defmodule Teiserver.Game.Match do field(:match_ended_at, :utc_datetime) # These will be something queried enough it's worth storing as it's own value + # it is also possible we will want to count the duration as something other than + # time passed between start and end, e.g. ignoring time spent paused field(:match_duration_seconds, :integer) - field(:player_count, :integer) # Memberships field(:lobby_id, Ecto.UUID) @@ -113,7 +115,7 @@ defmodule Teiserver.Game.Match do struct |> cast( attrs, - ~w(name tags public? rated? game_name game_version winning_team team_count team_size processed? lobby_opened_at match_started_at match_ended_at ended_normally? match_duration_seconds player_count host_id type_id lobby_id)a + ~w(id name tags public? rated? game_name game_version winning_team team_count team_size processed? lobby_opened_at match_started_at match_ended_at ended_normally? match_duration_seconds player_count host_id type_id lobby_id)a ) |> validate_required(~w(public? rated? host_id)a) end