Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Teifion committed Aug 8, 2024
1 parent 9850412 commit dc2a960
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/teiserver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/teiserver/account/queries/user_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 6 additions & 4 deletions lib/teiserver/game/schemas/match.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc2a960

Please sign in to comment.