From 6fce83d7830fbae9a13cab4cd01e15232d7b545f Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:43:33 +0200 Subject: [PATCH 01/22] Test and warning fixes --- .gitignore | 1 + .../account/servers/client_server.ex | 2 +- .../battle/servers/match_monitor_server.ex | 20 +++++++++---------- lib/teiserver/benchmark/stats_client.ex | 2 +- lib/teiserver/bridge/command_lib.ex | 1 - lib/teiserver/bridge/message_commands.ex | 4 ++-- lib/teiserver/coordinator/consul_server.ex | 4 ++-- lib/teiserver/helpers/oban_logger.ex | 2 +- lib/teiserver/lobby/libs/lobby_lib.ex | 6 +++--- lib/teiserver/protocols/spring/spring_in.ex | 4 ++-- lib/teiserver/protocols/spring/spring_out.ex | 2 +- .../protocols/spring/spring_system_in.ex | 2 -- .../protocols/spring/spring_telemetry_in.ex | 4 ++-- lib/teiserver/protocols/tachyon_lib.ex | 4 ++-- .../protocols/tachyon_v1/communication_out.ex | 2 +- .../protocols/tachyon_v1/tachyon_out.ex | 2 +- .../live/battles/lobbies/chat.ex | 2 +- .../live/microblog/admin/post/show.ex | 1 - .../live/microblog/admin/tag/index.ex | 1 - .../live/microblog/admin/tag/show.ex | 1 - lib/teiserver_web/live/queues/index.ex | 2 +- test/teiserver/account/account_test.exs | 7 ------- .../coordinator/consul_commands_test.exs | 20 +++++++++---------- .../coordinator/coordinator_commands_test.exs | 12 +++++------ .../coordinator/match_monitor_server_test.exs | 6 +++--- test/teiserver/coordinator/memes_test.exs | 10 +++++----- .../teiserver/coordinator/moderation_test.exs | 14 ++++++------- .../spring/spring_telemetry_test.exs | 18 ++++++++--------- .../complex_client_event_controller_test.exs | 2 +- .../live/microblog/blog/index_live_test.exs | 6 +++--- 30 files changed, 76 insertions(+), 88 deletions(-) diff --git a/.gitignore b/.gitignore index 06cd03941..1ae518ebd 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ runtime/ /source_deploy.tar.gz central.tar.gz /bin +.vscode/launch.json # I'm storing server output here, don't want to push it to git example_output diff --git a/lib/teiserver/account/servers/client_server.ex b/lib/teiserver/account/servers/client_server.ex index 5855858b8..b5bb0d29b 100644 --- a/lib/teiserver/account/servers/client_server.ex +++ b/lib/teiserver/account/servers/client_server.ex @@ -114,7 +114,7 @@ defmodule Teiserver.Account.ClientServer do end def handle_cast({:merge_update_client, partial_client}, state) do - Logger.warn(":merge_update_client is still being used, instead use :update_values") + Logger.warning(":merge_update_client is still being used, instead use :update_values") new_client = Map.merge(state.client, partial_client) PubSub.broadcast( diff --git a/lib/teiserver/battle/servers/match_monitor_server.ex b/lib/teiserver/battle/servers/match_monitor_server.ex index 770534678..91a0c2508 100644 --- a/lib/teiserver/battle/servers/match_monitor_server.ex +++ b/lib/teiserver/battle/servers/match_monitor_server.ex @@ -155,10 +155,10 @@ defmodule Teiserver.Battle.MatchMonitorServer do Telemetry.log_simple_match_event(userid, match_id, event_type_name, game_time) Logger.info("match-event: Stored <#{username}> <#{event_type_name}> <#{game_time}> userid #{userid} match_id #{match_id}") else - Logger.warn("match-event: Cannot get match_id of userid of #{username}") + Logger.warning("match-event: Cannot get match_id of userid of #{username}") end else - Logger.warn("match-event: Cannot get userid of #{username} or is not a bot") + Logger.warning("match-event: Cannot get userid of #{username} or is not a bot") end _ -> @@ -242,7 +242,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end _ -> - Logger.warn("match-chat nomatch from: #{from_id}: match-chat #{data}") + Logger.warning("match-chat nomatch from: #{from_id}: match-chat #{data}") end {:noreply, state} @@ -288,7 +288,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end _ -> - Logger.warn("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]") + Logger.warning("match-chat-name nomatch from: #{from_id}: match-chat [[#{data}]]") end {:noreply, state} @@ -311,15 +311,15 @@ defmodule Teiserver.Battle.MatchMonitorServer do handle_json_msg(data, from_id) _ -> - Logger.warn("AHM DM no catch, no json-decode - '#{contents_string}'") + Logger.warning("AHM DM no catch, no json-decode - '#{contents_string}'") end _ -> - Logger.warn("AHM DM no catch, no decompress - '#{compressed_contents}'") + Logger.warning("AHM DM no catch, no decompress - '#{compressed_contents}'") end _ -> - Logger.warn("AHM DM no catch, no base64 - '#{message}'") + Logger.warning("AHM DM no catch, no base64 - '#{message}'") end {:noreply, state} @@ -327,7 +327,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do # Catchall handle_info def handle_info(msg, state) do - Logger.warn( + Logger.warning( "Match monitor Server handle_info error. No handler for msg of #{Kernel.inspect(msg)}" ) @@ -337,7 +337,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do defp handle_json_msg(%{"username" => username, "GPU" => _} = contents, from_id) do case CacheUser.get_user_by_name(username) do nil -> - Logger.warn("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}") + Logger.warning("No username on handle_json_msg: #{username} - #{Kernel.inspect(contents)}") :ok @@ -367,7 +367,7 @@ defmodule Teiserver.Battle.MatchMonitorServer do end defp handle_json_msg(contents, _from_id) do - Logger.warn("No catch on handle_json_msg: #{Kernel.inspect(contents)}") + Logger.warning("No catch on handle_json_msg: #{Kernel.inspect(contents)}") :ok end diff --git a/lib/teiserver/benchmark/stats_client.ex b/lib/teiserver/benchmark/stats_client.ex index 6a2c88a95..8c78a49c9 100644 --- a/lib/teiserver/benchmark/stats_client.ex +++ b/lib/teiserver/benchmark/stats_client.ex @@ -43,7 +43,7 @@ Avg ping: #{round(average_ping * 100) / 100}ms, Pings: #{Enum.count(state.pings) port: port }) - Logger.warn("Starting stats") + Logger.warning("Starting stats") :timer.send_interval(@registration_interval, self(), :register) send(self(), :register) diff --git a/lib/teiserver/bridge/command_lib.ex b/lib/teiserver/bridge/command_lib.ex index 8034bc149..7332d0333 100644 --- a/lib/teiserver/bridge/command_lib.ex +++ b/lib/teiserver/bridge/command_lib.ex @@ -2,7 +2,6 @@ defmodule Teiserver.Bridge.CommandLib do @moduledoc """ """ - alias Teiserver.Data.Types, as: T require Logger @spec handle_command(Nostrum.Struct.Interaction.t(), map()) :: map() diff --git a/lib/teiserver/bridge/message_commands.ex b/lib/teiserver/bridge/message_commands.ex index a6a21dda2..d0734d28c 100644 --- a/lib/teiserver/bridge/message_commands.ex +++ b/lib/teiserver/bridge/message_commands.ex @@ -17,7 +17,7 @@ defmodule Teiserver.Bridge.MessageCommands do content: "$" <> content, attachments: [] }) do - Logger.warn("1") + Logger.warning("1") [cmd | remaining] = String.split(content, " ") remaining = Enum.join(remaining, " ") @@ -45,7 +45,7 @@ defmodule Teiserver.Bridge.MessageCommands do end def handle(_msg) do - # Logger.warn("2") + # Logger.warning("2") # IO.inspect msg :ok diff --git a/lib/teiserver/coordinator/consul_server.ex b/lib/teiserver/coordinator/consul_server.ex index 75d5eca7c..fc15bd7fd 100644 --- a/lib/teiserver/coordinator/consul_server.ex +++ b/lib/teiserver/coordinator/consul_server.ex @@ -657,7 +657,7 @@ defmodule Teiserver.Coordinator.ConsulServer do # if existing.ready == false and new_client.ready == true and existing.unready_at != nil do # time_elapsed = System.system_time(:millisecond) - existing.unready_at # if time_elapsed < 1000 do - # Logger.warn("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}") + # Logger.warning("Ready up in #{time_elapsed}ms by #{existing.userid}/#{existing.name} using #{existing.lobby_client}") # end # end @@ -686,7 +686,7 @@ defmodule Teiserver.Coordinator.ConsulServer do if player_count > 4 do if user.hw_hash == nil do - Logger.warn("hw hash block for #{Account.get_username(userid)}") + Logger.warning("hw hash block for #{Account.get_username(userid)}") %{new_client | player: false} else new_client diff --git a/lib/teiserver/helpers/oban_logger.ex b/lib/teiserver/helpers/oban_logger.ex index 6f969df33..77975c63d 100644 --- a/lib/teiserver/helpers/oban_logger.ex +++ b/lib/teiserver/helpers/oban_logger.ex @@ -3,7 +3,7 @@ defmodule Teiserver.Helper.ObanLogger do require Logger def handle_event([:oban, :job, :start], _measure, _meta, _) do - # Logger.warn("[Oban] :started #{meta.worker} at #{measure.system_time}") + # Logger.warning("[Oban] :started #{meta.worker} at #{measure.system_time}") end def handle_event([:oban, :job, :exception], _measure, meta, _) do diff --git a/lib/teiserver/lobby/libs/lobby_lib.ex b/lib/teiserver/lobby/libs/lobby_lib.ex index dfcbd4089..130699009 100644 --- a/lib/teiserver/lobby/libs/lobby_lib.ex +++ b/lib/teiserver/lobby/libs/lobby_lib.ex @@ -199,14 +199,14 @@ defmodule Teiserver.Lobby.LobbyLib do @spec update_lobby(T.lobby(), nil | atom, any) :: T.lobby() def update_lobby(%{id: lobby_id} = lobby, nil, :silent) do - Logger.warn("update_lobby is still being called for :silent") + Logger.warning("update_lobby is still being called for :silent") cast_lobby(lobby_id, {:update_lobby, lobby}) lobby end def update_lobby(%{id: lobby_id} = lobby, nil, reason) do - Logger.warn("update_lobby (no data) is still being called, reason: #{reason}") + Logger.warning("update_lobby (no data) is still being called, reason: #{reason}") cast_lobby(lobby_id, {:update_lobby, lobby}) PubSub.broadcast( @@ -224,7 +224,7 @@ defmodule Teiserver.Lobby.LobbyLib do end def update_lobby(%{id: lobby_id} = lobby, data, reason) do - Logger.warn("update_lobby (with data) is still being called, reason: #{reason}") + Logger.warning("update_lobby (with data) is still being called, reason: #{reason}") cast_lobby(lobby_id, {:update_lobby, lobby}) if Enum.member?([:update_battle_info], reason) do diff --git a/lib/teiserver/protocols/spring/spring_in.ex b/lib/teiserver/protocols/spring/spring_in.ex index 34a55fdb5..cd73a602d 100644 --- a/lib/teiserver/protocols/spring/spring_in.ex +++ b/lib/teiserver/protocols/spring/spring_in.ex @@ -1408,11 +1408,11 @@ defmodule Teiserver.Protocols.SpringIn do cond do Enum.count(status_timestamps) > 10 -> - Logger.warn("status_flood_protection:10 - #{state.username}/#{state.userid}") + Logger.warning("status_flood_protection:10 - #{state.username}/#{state.userid}") {true, %{state | status_timestamps: status_timestamps}} Enum.count(recent_timestamps) > 3 -> - Logger.warn("status_flood_protection:3 - #{state.username}/#{state.userid}") + Logger.warning("status_flood_protection:3 - #{state.username}/#{state.userid}") {true, %{state | status_timestamps: status_timestamps}} true -> diff --git a/lib/teiserver/protocols/spring/spring_out.ex b/lib/teiserver/protocols/spring/spring_out.ex index 4989f8c11..ec08fe695 100644 --- a/lib/teiserver/protocols/spring/spring_out.ex +++ b/lib/teiserver/protocols/spring/spring_out.ex @@ -855,7 +855,7 @@ defmodule Teiserver.Protocols.SpringOut do # I've made the mistake of forgetting it and wondering # why stuff wasn't working so it's staying here if not String.ends_with?(msg, "\n") do - Logger.warn("Attempting to send message without newline at the end - #{msg}") + Logger.warning("Attempting to send message without newline at the end - #{msg}") end msg = diff --git a/lib/teiserver/protocols/spring/spring_system_in.ex b/lib/teiserver/protocols/spring/spring_system_in.ex index be7c41230..c83271e6e 100644 --- a/lib/teiserver/protocols/spring/spring_system_in.ex +++ b/lib/teiserver/protocols/spring/spring_system_in.ex @@ -1,9 +1,7 @@ defmodule Teiserver.Protocols.Spring.SystemIn do @moduledoc false - alias Teiserver.Account.LoginThrottleServer alias Teiserver.Protocols.SpringIn - import Teiserver.Protocols.SpringOut, only: [reply: 5] require Logger @spec do_handle(String.t(), String.t(), String.t() | nil, Map.t()) :: Map.t() diff --git a/lib/teiserver/protocols/spring/spring_telemetry_in.ex b/lib/teiserver/protocols/spring/spring_telemetry_in.ex index 798710551..b867d04ce 100644 --- a/lib/teiserver/protocols/spring/spring_telemetry_in.ex +++ b/lib/teiserver/protocols/spring/spring_telemetry_in.ex @@ -156,9 +156,9 @@ defmodule Teiserver.Protocols.Spring.TelemetryIn do defp do_live_client_event(data, state) do if String.length(data) < 1024 do case Regex.run(~r/(\S+) (\S+)/u, data) do - [_, event_name, value64] -> + [_, _event_name, value64] -> case Spring.decode_value(value64) do - {:ok, value} -> + {:ok, _value} -> if state.userid do # TODO: Do stuff with live client events # Telemetry.log_live_client_event(state.userid, event_name, value) diff --git a/lib/teiserver/protocols/tachyon_lib.ex b/lib/teiserver/protocols/tachyon_lib.ex index a6b3b77d7..3ef48e818 100644 --- a/lib/teiserver/protocols/tachyon_lib.ex +++ b/lib/teiserver/protocols/tachyon_lib.ex @@ -56,11 +56,11 @@ defmodule Teiserver.Protocols.TachyonLib do :error -> # Previously got an error with data 'OK cmd=TACHYON' which suggests # it was still in Spring mode - Logger.warn("Base64 error, given '#{data}'") + Logger.warning("Base64 error, given '#{data}'") {:error, :base64_decode} {:error, :gzip_decompress} -> - Logger.warn("Gzip error, given '#{data}'") + Logger.warning("Gzip error, given '#{data}'") {:error, :gzip_decompress} {:error, %Jason.DecodeError{}} -> diff --git a/lib/teiserver/protocols/tachyon_v1/communication_out.ex b/lib/teiserver/protocols/tachyon_v1/communication_out.ex index 533e1afe8..9b9e7fb4a 100644 --- a/lib/teiserver/protocols/tachyon_v1/communication_out.ex +++ b/lib/teiserver/protocols/tachyon_v1/communication_out.ex @@ -7,7 +7,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.CommunicationOut do ########### # Direct messages def do_reply(:direct_message, {sender_id, msg}) do - Logger.warn( + Logger.warning( "Using :direct_message instead of :received_direct_message in V1.CommunicationOut" ) diff --git a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex b/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex index 62765c7be..5f709c6ec 100644 --- a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex +++ b/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex @@ -43,7 +43,7 @@ defmodule Teiserver.Protocols.Tachyon.V1.TachyonOut do LobbyOut.do_reply(reply_cmd, data) :battle -> - Logger.warn("Tachyon :battle namespace message #{reply_cmd}") + Logger.warning("Tachyon :battle namespace message #{reply_cmd}") LobbyOut.do_reply(reply_cmd, data) :matchmaking -> diff --git a/lib/teiserver_web/live/battles/lobbies/chat.ex b/lib/teiserver_web/live/battles/lobbies/chat.ex index 00a6e33c8..e60d5b216 100644 --- a/lib/teiserver_web/live/battles/lobbies/chat.ex +++ b/lib/teiserver_web/live/battles/lobbies/chat.ex @@ -245,7 +245,7 @@ defmodule TeiserverWeb.Battle.LobbyLive.Chat do end def handle_info(msg, socket) do - Logger.warn("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}") + Logger.warning("No handler in #{__MODULE__} for message #{Kernel.inspect(msg)}") {:noreply, socket} end diff --git a/lib/teiserver_web/live/microblog/admin/post/show.ex b/lib/teiserver_web/live/microblog/admin/post/show.ex index 46e0ec5fc..c98e3a7ed 100644 --- a/lib/teiserver_web/live/microblog/admin/post/show.ex +++ b/lib/teiserver_web/live/microblog/admin/post/show.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.PostLive.Show do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/microblog/admin/tag/index.ex b/lib/teiserver_web/live/microblog/admin/tag/index.ex index 965fca837..3557d46f7 100644 --- a/lib/teiserver_web/live/microblog/admin/tag/index.ex +++ b/lib/teiserver_web/live/microblog/admin/tag/index.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Index do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/microblog/admin/tag/show.ex b/lib/teiserver_web/live/microblog/admin/tag/show.ex index 54a0540bc..1f8ca4359 100644 --- a/lib/teiserver_web/live/microblog/admin/tag/show.ex +++ b/lib/teiserver_web/live/microblog/admin/tag/show.ex @@ -2,7 +2,6 @@ defmodule TeiserverWeb.Microblog.Admin.TagLive.Show do @moduledoc false use TeiserverWeb, :live_view alias Teiserver.Microblog - import TeiserverWeb.MicroblogComponents @impl true def mount(_params, _session, socket) do diff --git a/lib/teiserver_web/live/queues/index.ex b/lib/teiserver_web/live/queues/index.ex index ad7c47955..380952fc8 100644 --- a/lib/teiserver_web/live/queues/index.ex +++ b/lib/teiserver_web/live/queues/index.ex @@ -206,7 +206,7 @@ defmodule TeiserverWeb.Matchmaking.QueueLive.Index do } = data, socket ) do - Logger.warn("index.ex Match ready") + Logger.warning("index.ex Match ready") {:noreply, socket diff --git a/test/teiserver/account/account_test.exs b/test/teiserver/account/account_test.exs index dbafaf806..5ed055818 100644 --- a/test/teiserver/account/account_test.exs +++ b/test/teiserver/account/account_test.exs @@ -78,13 +78,6 @@ defmodule Teiserver.AccountTest do developer: "Normal" ] ) - - # Order by - Account.list_users(order_by: [{:data, "field", :asc}]) - Account.list_users(order_by: [{:data, "field", :desc}]) - - # Fallback - Account.list_users(order_by: [{:data, "field", :desc}]) end test "get_user!/1 returns the user with given id" do diff --git a/test/teiserver/coordinator/consul_commands_test.exs b/test/teiserver/coordinator/consul_commands_test.exs index 48bee636a..b367de54e 100644 --- a/test/teiserver/coordinator/consul_commands_test.exs +++ b/test/teiserver/coordinator/consul_commands_test.exs @@ -456,13 +456,13 @@ defmodule Teiserver.Coordinator.ConsulCommandsTest do # Minimum assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 0 - data = %{cmd: "c.lobby.message", message: "$minplaylevel 3"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel 3"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 3 - data = %{cmd: "c.lobby.message", message: "$minplaylevel Xy"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel Xy"} _tachyon_send(hsocket, data) :timer.sleep(500) @@ -471,52 +471,52 @@ defmodule Teiserver.Coordinator.ConsulCommandsTest do # Maximum assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 1000 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 13"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 13"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel Xy"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel Xy"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 # Now try to set each the other side of the other - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 1"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 1"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 4 - data = %{cmd: "c.lobby.message", message: "$maxplaylevel 16"} + data = %{cmd: "c.lobby.message", message: "$maxratinglevel 16"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 16 - data = %{cmd: "c.lobby.message", message: "$minplaylevel 20"} + data = %{cmd: "c.lobby.message", message: "$minratinglevel 20"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 15 - data = %{cmd: "c.lobby.message", message: "$setplaylevels 7 9"} + data = %{cmd: "c.lobby.message", message: "$setratinglevels 7 9"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 7 assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 9 - data = %{cmd: "c.lobby.message", message: "$setplaylevels 50 33"} + data = %{cmd: "c.lobby.message", message: "$setratinglevels 50 33"} _tachyon_send(hsocket, data) :timer.sleep(500) assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 33 assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 50 - data = %{cmd: "c.lobby.message", message: "$resetplaylevels"} + data = %{cmd: "c.lobby.message", message: "$resetratinglevels"} _tachyon_send(hsocket, data) :timer.sleep(500) diff --git a/test/teiserver/coordinator/coordinator_commands_test.exs b/test/teiserver/coordinator/coordinator_commands_test.exs index eb5667a17..c8f79fd0a 100644 --- a/test/teiserver/coordinator/coordinator_commands_test.exs +++ b/test/teiserver/coordinator/coordinator_commands_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Coordinator, Account} + alias Teiserver.{CacheUser, Coordinator, Account} import Teiserver.TeiserverTestLib, only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1, new_user: 0] @@ -44,7 +44,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do assert String.contains?(message, "$whoami") # Moderator help test - User.update_user(%{user | moderator: true}) + CacheUser.update_user(%{user | moderator: true}) message_coordinator(socket, "$help") [reply] = _tachyon_recv(socket) assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} @@ -94,7 +94,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do refute String.contains?(message, "Displays this help text.") # Moderator pull test - User.update_user(%{user | moderator: true}) + CacheUser.update_user(%{user | moderator: true}) message_coordinator(socket, "$help pull") [reply] = _tachyon_recv(socket) assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} @@ -195,7 +195,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [user2.id] # Now use it again, make sure we don't get a crash @@ -211,7 +211,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [] # Now unmute again @@ -227,7 +227,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommandsTest do "sender_id" => coordinator_userid } - user = User.get_user_by_id(user.id) + user = CacheUser.get_user_by_id(user.id) assert user.ignored == [] end diff --git a/test/teiserver/coordinator/match_monitor_server_test.exs b/test/teiserver/coordinator/match_monitor_server_test.exs index 6bb8225ee..34bee7a12 100644 --- a/test/teiserver/coordinator/match_monitor_server_test.exs +++ b/test/teiserver/coordinator/match_monitor_server_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Chat, Client, Lobby} + alias Teiserver.{CacheUser, Chat, Client, Lobby} alias Teiserver.Coordinator.{CoordinatorServer} import Teiserver.TeiserverTestLib, @@ -13,7 +13,7 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do Teiserver.Battle.start_match_monitor() %{socket: hsocket, user: host} = tachyon_auth_setup() %{socket: psocket, user: player} = tachyon_auth_setup() - User.update_user(%{host | bot: true}) + CacheUser.update_user(%{host | bot: true}) battle_data = %{ cmd: "c.lobby.create", @@ -56,7 +56,7 @@ defmodule Teiserver.Coordinator.MatchMonitorServerTest do end test "chat messages", %{hsocket: hsocket, host: host, player: player} do - monitor_user = User.get_user_by_name("AutohostMonitor") + monitor_user = CacheUser.get_user_by_name("AutohostMonitor") messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) diff --git a/test/teiserver/coordinator/memes_test.exs b/test/teiserver/coordinator/memes_test.exs index 2feb8aa68..d467b1835 100644 --- a/test/teiserver/coordinator/memes_test.exs +++ b/test/teiserver/coordinator/memes_test.exs @@ -1,7 +1,7 @@ defmodule Teiserver.Coordinator.MemesTest do use Teiserver.ServerCase, async: false alias Teiserver.Account.ClientLib - alias Teiserver.{User, Client, Coordinator, Lobby} + alias Teiserver.{CacheUser, Client, Coordinator, Lobby} require Logger import Teiserver.TeiserverTestLib, @@ -13,7 +13,7 @@ defmodule Teiserver.Coordinator.MemesTest do %{socket: psocket, user: player} = tachyon_auth_setup() # User needs to be a moderator (at this time) to start/stop Coordinator mode - User.update_user(%{host | moderator: true}) + CacheUser.update_user(%{host | moderator: true}) ClientLib.refresh_client(host.id) lobby_data = %{ @@ -73,7 +73,7 @@ defmodule Teiserver.Coordinator.MemesTest do assert reply == %{ "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, + "lobby_id" => lobby_id, "new_values" => %{ "disabled_units" => ~w(armaap armalab armap armavp armhp armshltx armvp armamsub armasy armfhp armplat armshltxuw armsy armmg armllt armbeamer armhlt arm armdrag armclaw armguard armjuno armham armjeth armpw armrectr armrock armwar coraap coralab corap coravp corgant corhp corlab corvp corllt corfhp corsy corjuno corhllt corhlt) @@ -102,7 +102,7 @@ defmodule Teiserver.Coordinator.MemesTest do "cmd" => "s.lobby.set_modoptions", "lobby_id" => lobby_id, "new_options" => %{ - "game/modoptions/resourceincomemultiplier" => "0" + "game/modoptions/multiplier_resourceincome" => "0" } } end @@ -115,7 +115,7 @@ defmodule Teiserver.Coordinator.MemesTest do "cmd" => "s.lobby.set_modoptions", "lobby_id" => lobby_id, "new_options" => %{ - "game/modoptions/resourceincomemultiplier" => "1000", + "game/modoptions/multiplier_resourceincome" => "1000", "game/modoptions/startenergy" => "100000000", "game/modoptions/startmetal" => "100000000" } diff --git a/test/teiserver/coordinator/moderation_test.exs b/test/teiserver/coordinator/moderation_test.exs index 738ba88a6..64b2d0aee 100644 --- a/test/teiserver/coordinator/moderation_test.exs +++ b/test/teiserver/coordinator/moderation_test.exs @@ -1,6 +1,6 @@ defmodule Teiserver.Coordinator.ModerationTest do use Teiserver.ServerCase, async: false - alias Teiserver.{User, Coordinator, Client, Moderation} + alias Teiserver.{CacheUser, Coordinator, Client, Moderation} import Teiserver.Helper.TimexHelper, only: [date_to_str: 2] alias Teiserver.Moderation.RefreshUserRestrictionsTask @@ -16,9 +16,9 @@ defmodule Teiserver.Coordinator.ModerationTest do test "login with warning", %{user: user} do delay = Teiserver.Config.get_site_config_cache("teiserver.Post login action delay") - refute User.has_warning?(user.id) - refute User.has_mute?(user.id) - refute User.is_restricted?(user.id, ["Login"]) + refute CacheUser.has_warning?(user.id) + refute CacheUser.has_mute?(user.id) + refute CacheUser.is_restricted?(user.id, ["Login"]) {:ok, action} = Moderation.create_action(%{ @@ -33,9 +33,9 @@ defmodule Teiserver.Coordinator.ModerationTest do RefreshUserRestrictionsTask.refresh_user(user.id) # Did it take? - assert User.has_warning?(user.id) - refute User.has_mute?(user.id) - refute User.is_restricted?(user.id, ["Login"]) + assert CacheUser.has_warning?(user.id) + refute CacheUser.has_mute?(user.id) + refute CacheUser.is_restricted?(user.id, ["Login"]) # Now login %{socket: socket} = tachyon_auth_setup(user) diff --git a/test/teiserver/protocols/spring/spring_telemetry_test.exs b/test/teiserver/protocols/spring/spring_telemetry_test.exs index 4d75fe6cf..2739f06fa 100644 --- a/test/teiserver/protocols/spring/spring_telemetry_test.exs +++ b/test/teiserver/protocols/spring/spring_telemetry_test.exs @@ -100,16 +100,16 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 0 - assert Enum.count(Telemetry.list_client_events()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 + assert Enum.count(Telemetry.list_complex_client_events()) == 0 # Good data _send_raw(socket, "c.telemetry.log_client_event event_name e30= TXlWYWx1ZUdvZXNoZXJl\n") reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 0 - assert Enum.count(Telemetry.list_client_events()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 + assert Enum.count(Telemetry.list_complex_client_events()) == 1 # Unauth %{socket: socket_raw} = raw_setup() @@ -118,8 +118,8 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket_raw) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_events()) == 1 - assert Enum.count(Telemetry.list_client_events()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 1 + assert Enum.count(Telemetry.list_complex_client_events()) == 1 end test "update_client_property call", %{socket: socket} do @@ -132,7 +132,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 assert Enum.count(Telemetry.list_client_properties()) == 0 # Good data @@ -144,7 +144,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 0 + assert Enum.count(Telemetry.list_complex_anon_events()) == 0 assert Enum.count(Telemetry.list_client_properties()) == 1 # Unauth @@ -159,7 +159,7 @@ defmodule Teiserver.SpringTelemetryTest do reply = _recv_raw(socket_raw) assert reply == :timeout - assert Enum.count(Telemetry.list_anon_properties()) == 1 + assert Enum.count(Telemetry.list_complex_anon_events()) == 1 assert Enum.count(Telemetry.list_client_properties()) == 1 end end diff --git a/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs b/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs index ad465186e..6c14e0949 100644 --- a/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs +++ b/test/teiserver_web/controllers/report/complex_client_event_controller_test.exs @@ -9,7 +9,7 @@ defmodule TeiserverWeb.Report.ComplexClientEventControllerTest do end test "index", %{conn: conn} do - conn = get(conn, ~p"/telemetry/complex_client/summary") + conn = get(conn, ~p"/telemetry/complex_client_events/summary") assert html_response(conn, 200) end diff --git a/test/teiserver_web/live/microblog/blog/index_live_test.exs b/test/teiserver_web/live/microblog/blog/index_live_test.exs index 6ba5f660e..f6137ea31 100644 --- a/test/teiserver_web/live/microblog/blog/index_live_test.exs +++ b/test/teiserver_web/live/microblog/blog/index_live_test.exs @@ -17,15 +17,15 @@ defmodule TeiserverWeb.Microblog.Blog.IndexLiveTest do tag2 = tag_fixture() tag3 = tag_fixture() - post1 = post_fixture(title: "Post 1 title", contents: "Post 1 line1\n\nPost 1 fold line") + post1 = post_fixture(title: "Post 1 title", summary: "Post 1 line1", contents: "Post 1 line1\n\nPost 1 fold line") _post1_tag1 = post_tag_fixture(post_id: post1.id, tag_id: tag1.id) _post1_tag2 = post_tag_fixture(post_id: post1.id, tag_id: tag2.id) - post2 = post_fixture(title: "Post 2 title", contents: "Post 2 line1\n\nPost 2 fold line") + post2 = post_fixture(title: "Post 2 title", summary: "Post 2 line1", contents: "Post 2 line1\n\nPost 2 fold line") _post2_tag1 = post_tag_fixture(post_id: post2.id, tag_id: tag1.id) _post2_tag3 = post_tag_fixture(post_id: post2.id, tag_id: tag3.id) - post3 = post_fixture(title: "Post 3 title", contents: "Post 3 line1\n\nPost 3 fold line") + post3 = post_fixture(title: "Post 3 title", summary: "Post 3 line1", contents: "Post 3 line1\n\nPost 3 fold line") _post3_tag2 = post_tag_fixture(post_id: post3.id, tag_id: tag2.id) _post3_tag3 = post_tag_fixture(post_id: post3.id, tag_id: tag3.id) From 96c943e0647794c5e8b1350c9a065575056ffc1d Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 14:08:26 +0200 Subject: [PATCH 02/22] Split Team ratings into Small team and big team --- .../account/reports/mapping_report.ex | 3 +- .../account/reports/open_skill_report.ex | 2 +- .../account/reports/user_age_report.ex | 4 +- .../tasks/recalculate_user_cache_task.ex | 15 ++- lib/teiserver/battle/libs/match_lib.ex | 11 ++- .../battle/tasks/breakdown_match_data_task.ex | 3 +- .../tasks/export_raw_match_metrics_task.ex | 2 +- lib/teiserver/coordinator/consul_server.ex | 4 +- lib/teiserver/game/libs/match_rating_lib.ex | 7 +- lib/teiserver/game/servers/balancer_server.ex | 7 +- lib/teiserver/libs/test_lib.ex | 3 +- .../logging/tasks/match_graph_logs_task.ex | 9 +- .../logging/tasks/persist_server_day_task.ex | 3 +- lib/teiserver/mix_tasks/fake_data.ex | 8 +- lib/teiserver/mix_tasks/team_rating.ex | 93 +++++++++++++++++++ .../controllers/admin/match_controller.ex | 5 +- .../controllers/api/spads_controller.ex | 5 +- .../controllers/report/rating_controller.ex | 2 +- .../live/moderation/report_user/index.ex | 2 +- .../templates/admin/match/search.html.heex | 3 +- .../templates/admin/user/ratings.html.heex | 6 +- .../report/report/open_skill.html.heex | 3 +- .../report/report/user_age.html.heex | 3 +- test/teiserver/account/accolade_bot_test.exs | 2 +- 24 files changed, 167 insertions(+), 38 deletions(-) create mode 100644 lib/teiserver/mix_tasks/team_rating.ex diff --git a/lib/teiserver/account/reports/mapping_report.ex b/lib/teiserver/account/reports/mapping_report.ex index 22cd37fd4..ac7f95ace 100644 --- a/lib/teiserver/account/reports/mapping_report.ex +++ b/lib/teiserver/account/reports/mapping_report.ex @@ -27,8 +27,7 @@ defmodule Teiserver.Game.MappingReport do search: [ started_after: start_date |> Timex.to_datetime(), started_before: end_date |> Timex.to_datetime(), - # game_type_in: ["Duel", "Team", "FFA", "Team FFA"], - game_type_in: ["Duel", "Team"], + game_type_in: ["Duel", "Small Team", "Big Team"], of_interest: true, has_winning_team: true ], diff --git a/lib/teiserver/account/reports/open_skill_report.ex b/lib/teiserver/account/reports/open_skill_report.ex index 7017b8ea9..545c4ec20 100644 --- a/lib/teiserver/account/reports/open_skill_report.ex +++ b/lib/teiserver/account/reports/open_skill_report.ex @@ -69,7 +69,7 @@ defmodule Teiserver.Account.OpenSkillReport do defp apply_defaults(params) do Map.merge( %{ - "rating_type" => "Team", + "rating_type" => "Big Team", "metric" => "Game Rating", "last_active" => "7 days", "uncertainty" => "5" diff --git a/lib/teiserver/account/reports/user_age_report.ex b/lib/teiserver/account/reports/user_age_report.ex index 2be17205e..3f0f7d07e 100644 --- a/lib/teiserver/account/reports/user_age_report.ex +++ b/lib/teiserver/account/reports/user_age_report.ex @@ -48,7 +48,9 @@ defmodule Teiserver.Account.UserAgeReport do type_where = case params["game_type"] do "Duel" -> "AND m.game_type = 'Duel'" - "Team" -> "AND m.game_type = 'Team'" + "Team" -> "AND m.game_type IN ('Small Team', 'Big Team')" + "Small Team" -> "AND m.game_type = 'Small Team'" + "Big Team" -> "AND m.game_type = 'Big Team'" "FFA" -> "AND m.game_type = 'FFA'" "Raptors" -> "AND m.game_type = 'Raptors'" "Scavengers" -> "AND m.game_type = 'Scavengers'" diff --git a/lib/teiserver/account/tasks/recalculate_user_cache_task.ex b/lib/teiserver/account/tasks/recalculate_user_cache_task.ex index e3e2d1da0..34e912c6f 100644 --- a/lib/teiserver/account/tasks/recalculate_user_cache_task.ex +++ b/lib/teiserver/account/tasks/recalculate_user_cache_task.ex @@ -19,7 +19,8 @@ defmodule Teiserver.Account.RecacheUserStatsTask do case match.game_type do "Duel" -> do_match_processed_duel(userid) "FFA" -> do_match_processed_duel(userid) - "Team" -> do_match_processed_team(userid) + "Small Team" -> do_match_processed_team_small(userid) + "Big Team" -> do_match_processed_team_big(userid) _ -> :ok end @@ -105,8 +106,16 @@ defmodule Teiserver.Account.RecacheUserStatsTask do :ok end - def do_match_processed_team(userid) do - filter_type_id = MatchRatingLib.rating_type_name_lookup()["Team"] + def do_match_processed_team_big(userid) do + do_match_processed_team(userid, "Big Team") + end + + def do_match_processed_team_small(userid) do + do_match_processed_team(userid, "Small Team") + end + + defp do_match_processed_team(userid, team_subtype) do + filter_type_id = MatchRatingLib.rating_type_name_lookup()[team_subtype] logs = Game.list_rating_logs( diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index fd883e966..d6a18be81 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -38,7 +38,8 @@ defmodule Teiserver.Battle.MatchLib do String.contains?(bot_names, "Raptor") -> "Raptors" Enum.empty?(bots) == false -> "Bots" Enum.count(teams) == 2 and max_team_size == 1 -> "Duel" - Enum.count(teams) == 2 -> "Team" + Enum.count(teams) == 2 and max_team_size <= 4 -> "Small Team" # 2v2, 3v3, 4v4 + Enum.count(teams) == 2 and max_team_size > 4 -> "Big Team" # 5v5, 6v6, 7v7, 8v8 max_team_size == 1 -> "FFA" true -> "Team FFA" end @@ -47,7 +48,8 @@ defmodule Teiserver.Battle.MatchLib do def list_game_types() do [ "Duel", - "Team", + "Small Team", + "Big Team", "FFA", "Team FFA", "Raptors", @@ -59,7 +61,8 @@ defmodule Teiserver.Battle.MatchLib do def list_rated_game_types() do [ "Duel", - "Team", + "Small Team", + "Big Team", "FFA", "Team FFA" ] @@ -142,7 +145,7 @@ defmodule Teiserver.Battle.MatchLib do def make_match_name(match) do case match.game_type do "Duel" -> "Duel on #{match.map}" - "Team" -> "#{match.team_size}v#{match.team_size} on #{match.map}" + type when type in ["Small Team", "Big Team"] -> "#{match.team_size}v#{match.team_size} on #{match.map}" "FFA" -> "#{match.team_count} way FFA on #{match.map}" t -> "#{t} game on #{match.map}" end diff --git a/lib/teiserver/battle/tasks/breakdown_match_data_task.ex b/lib/teiserver/battle/tasks/breakdown_match_data_task.ex index 2e06c3484..ffb82c1d1 100644 --- a/lib/teiserver/battle/tasks/breakdown_match_data_task.ex +++ b/lib/teiserver/battle/tasks/breakdown_match_data_task.ex @@ -19,7 +19,8 @@ defmodule Teiserver.Battle.Tasks.BreakdownMatchDataTask do %{ duel: get_subset_data(matches, game_type: "Duel"), - team: get_subset_data(matches, game_type: "Team"), + small_team: get_subset_data(matches, game_type: "Small Team"), + big_team: get_subset_data(matches, game_type: "Big Team"), ffa: get_subset_data(matches, game_type: "FFA"), team_ffa: get_subset_data(matches, game_type: "Team FFA"), scavengers: get_subset_data(matches, game_type: "Scavengers"), diff --git a/lib/teiserver/battle/tasks/export_raw_match_metrics_task.ex b/lib/teiserver/battle/tasks/export_raw_match_metrics_task.ex index 8f4a5f63d..59a8b45a3 100644 --- a/lib/teiserver/battle/tasks/export_raw_match_metrics_task.ex +++ b/lib/teiserver/battle/tasks/export_raw_match_metrics_task.ex @@ -31,7 +31,7 @@ defmodule Teiserver.Battle.ExportRawMatchMetricsTask do defp do_output(data, _params) do data |> Stream.filter(fn match -> - match.game_type == "Team" + match.game_type in ["Small Team", "Big Team"] end) |> Stream.map(fn match -> members = diff --git a/lib/teiserver/coordinator/consul_server.ex b/lib/teiserver/coordinator/consul_server.ex index 75d5eca7c..041c01103 100644 --- a/lib/teiserver/coordinator/consul_server.ex +++ b/lib/teiserver/coordinator/consul_server.ex @@ -827,7 +827,9 @@ defmodule Teiserver.Coordinator.ConsulServer do player_list = list_players(state) {player_rating, player_uncertainty} = - BalanceLib.get_user_rating_value_uncertainty_pair(user.id, "Team") + # TODO FIX THIS BUG + # Teiserver.Battle.MatchLib.game_type/2 maybe to check for game type to get ratings for? + BalanceLib.get_user_rating_value_uncertainty_pair(user.id, "Big Team") player_rating = max(player_rating, 1) avoid_status = Account.check_avoid_status(user.id, player_list) diff --git a/lib/teiserver/game/libs/match_rating_lib.ex b/lib/teiserver/game/libs/match_rating_lib.ex index 483c475f5..8e9421bb6 100644 --- a/lib/teiserver/game/libs/match_rating_lib.ex +++ b/lib/teiserver/game/libs/match_rating_lib.ex @@ -10,7 +10,7 @@ defmodule Teiserver.Game.MatchRatingLib do alias Teiserver.Battle.{BalanceLib, MatchLib} require Logger - @rated_match_types ["Team", "Duel", "FFA", "Team FFA", "Partied Team"] + @rated_match_types ["Small Team", "Big Team", "Duel", "FFA", "Team FFA", "Partied Team"] @spec rating_type_list() :: [String.t()] def rating_type_list() do @@ -191,7 +191,7 @@ defmodule Teiserver.Game.MatchRatingLib do rate_result = rate_with_ids([winner_ratings, loser_ratings], as_map: true) status_lookup = - if match.game_type == "Team" do + if match.game_type in ["Small Team", "Big Team"] do match.members |> Map.new(fn membership -> {membership.user_id, @@ -357,7 +357,7 @@ defmodule Teiserver.Game.MatchRatingLib do win_result = Map.new(win_result) status_lookup = - if Enum.member?(["Team", "Team FFA"], match.game_type) do + if Enum.member?(["Small Team", "Big Team", "Team FFA"], match.game_type) do match.members |> Map.new(fn membership -> {membership.user_id, @@ -771,7 +771,6 @@ defmodule Teiserver.Game.MatchRatingLib do results = Battle.list_matches( search: [ - # game_type_in: ["Team"], game_type_in: @rated_match_types, processed: true, started_after: Timex.now() |> Timex.shift(days: -31) diff --git a/lib/teiserver/game/servers/balancer_server.ex b/lib/teiserver/game/servers/balancer_server.ex index ab890ada1..5bb1c392a 100644 --- a/lib/teiserver/game/servers/balancer_server.ex +++ b/lib/teiserver/game/servers/balancer_server.ex @@ -169,10 +169,13 @@ defmodule Teiserver.Game.BalancerServer do "Duel" team_count > 2 -> - if player_count > team_count, do: "Team", else: "FFA" + if player_count > team_count, do: "Big Team", else: "FFA" + + team_count == 2 -> + if player_count > 8, do: "Big Team", else: "Small Team" true -> - "Team" + "Big Team" end if opts[:allow_groups] do diff --git a/lib/teiserver/libs/test_lib.ex b/lib/teiserver/libs/test_lib.ex index 7bd4392c3..0fda8cd45 100644 --- a/lib/teiserver/libs/test_lib.ex +++ b/lib/teiserver/libs/test_lib.ex @@ -614,7 +614,8 @@ defmodule Teiserver.TeiserverTestLib do Teiserver.Account.get_or_add_smurf_key_type("hw3") Teiserver.Game.get_or_add_rating_type("Duel") - Teiserver.Game.get_or_add_rating_type("Team") + Teiserver.Game.get_or_add_rating_type("Small Team") + Teiserver.Game.get_or_add_rating_type("Big Team") Teiserver.Game.get_or_add_rating_type("FFA") Teiserver.Telemetry.get_or_add_complex_server_event_type("Server startup") diff --git a/lib/teiserver/logging/tasks/match_graph_logs_task.ex b/lib/teiserver/logging/tasks/match_graph_logs_task.ex index eead41702..8fa33882f 100644 --- a/lib/teiserver/logging/tasks/match_graph_logs_task.ex +++ b/lib/teiserver/logging/tasks/match_graph_logs_task.ex @@ -5,7 +5,8 @@ defmodule Teiserver.Logging.MatchGraphLogsTask do def perform(logs, "split", key) do [ {"Duel", "duel.aggregate.#{key}"}, - {"Team", "team.aggregate.#{key}"}, + {"Small Team", "team.aggregate.#{key}"}, + {"Big Team", "team.aggregate.#{key}"}, {"FFA", "ffa.aggregate.#{key}"}, {"Team FFA", "team_ffa.aggregate.#{key}"}, {"Bot", "bots.aggregate.#{key}"}, @@ -34,7 +35,8 @@ defmodule Teiserver.Logging.MatchGraphLogsTask do pvp = Map.get(l.data["duel"]["aggregate"], key, 0) + Map.get(l.data["ffa"]["aggregate"], key, 0) + - Map.get(l.data["team"]["aggregate"], key, 0) + + Map.get(l.data["small_team"]["aggregate"], key, 0) + + Map.get(l.data["big_team"]["aggregate"], key, 0) + Map.get(l.data["team_ffa"]["aggregate"], key, 0) pve = @@ -84,7 +86,8 @@ defmodule Teiserver.Logging.MatchGraphLogsTask do pvp = Map.get(l.data["duel"]["aggregate"], key, 0) + Map.get(l.data["ffa"]["aggregate"], key, 0) + - Map.get(l.data["team"]["aggregate"], key, 0) + Map.get(l.data["big_team"]["aggregate"], key, 0) + + Map.get(l.data["team_ffa"]["aggregate"], key, 0) coop = Map.get(l.data["raptors"]["aggregate"], key, 0) + diff --git a/lib/teiserver/logging/tasks/persist_server_day_task.ex b/lib/teiserver/logging/tasks/persist_server_day_task.ex index d14cd8a96..18a8a337e 100644 --- a/lib/teiserver/logging/tasks/persist_server_day_task.ex +++ b/lib/teiserver/logging/tasks/persist_server_day_task.ex @@ -562,7 +562,8 @@ defmodule Teiserver.Logging.Tasks.PersistServerDayTask do "Raptors" -> :raptors "Bots" -> :bots "Duel" -> :duel - "Team" -> :team + "Small Team" -> :small_team + "Big Team" -> :big_team "FFA" -> :ffa "Team FFA" -> :team_ffa end diff --git a/lib/teiserver/mix_tasks/fake_data.ex b/lib/teiserver/mix_tasks/fake_data.ex index dd5f02777..e217e99df 100644 --- a/lib/teiserver/mix_tasks/fake_data.ex +++ b/lib/teiserver/mix_tasks/fake_data.ex @@ -331,6 +331,12 @@ defmodule Mix.Tasks.Teiserver.Fakedata do team1 = shuffled_users |> Enum.take(team_size) team2 = shuffled_users |> Enum.reverse() |> Enum.take(team_size) + game_type = cond do + team_size == 1 -> "Duel" + team_size <= 4 -> "Small Team" + true -> "Big Team" + end + team1_score = team1 |> Enum.map(fn {_, name} -> String.length(name) end) @@ -356,7 +362,7 @@ defmodule Mix.Tasks.Teiserver.Fakedata do team_size: team_size, passworded: false, processed: true, - game_type: if(team_size == 1, do: "Duel", else: "Team"), + game_type: game_type, # All rooms are hosted by the same user for now founder_id: 1, diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex new file mode 100644 index 000000000..272a659fc --- /dev/null +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -0,0 +1,93 @@ +defmodule Mix.Tasks.Teiserver.Teamrating do + @moduledoc """ + Run with mix teiserver.teamrating + Goes through every existing 'Team' rating and sorts it into either 'Small Team' or 'Big Team' rating category based on team size. + Recalculates 'Small Team' and 'Big Team' ratings for affected players. + """ + + use Mix.Task + + alias Teiserver.Battle + + require Logger + + @spec run(list()) :: :ok + def run(args) do + Application.ensure_all_started(:teiserver) + + rate = case args do + ["true"] -> true + _ -> false + end + + Logger.debug("Starting to process small team games..") + process_small_team_games() + Logger.debug("Finished processing small team games") + + Logger.debug("Starting to process big team games") + process_big_team_games(rate) + Logger.debug("Finished processing big team games") + end + + defp process_small_team_games() do + # Get all small team matches + small_team_matches = + Battle.list_matches( + search: [ + server_uuid_not_nil: true, + game_type: "Team", + team_size_less_than: 5 + ], + limit: :infinity, + preload: [:members] + ) + + Logger.debug("Found #{Enum.count(small_team_matches)} small team game matches") + + # For small team games change game type and update rating + small_team_matches + |> Enum.chunk_every(50) + |> Enum.each(fn chunk -> + chunk + |> Enum.each(fn match -> + Battle.update_match(match, %{ + game_type: "Small Team" + }) + + Teiserver.rate_match(match) + end) + end) + end + + defp process_big_team_games(rate_big_games) do + # Get all big team matches + big_team_matches = + Battle.list_matches( + search: [ + server_uuid_not_nil: true, + game_type: "Team", + team_size_greater_than: 4 + ], + limit: :infinity + ) + + Logger.debug("Found #{Enum.count(big_team_matches)} big team game matches") + + # For big team games only change game type + big_team_matches + |> Enum.chunk_every(50) + |> Enum.each(fn chunk -> + chunk + |> Enum.each(fn match -> + Battle.update_match(match, %{ + game_type: "Big Team" + }) + + if rate_big_games do + Logger.debug("RATING") + Teiserver.rate_match(match) + end + end) + end) + end +end diff --git a/lib/teiserver_web/controllers/admin/match_controller.ex b/lib/teiserver_web/controllers/admin/match_controller.ex index 9a8e81435..a17c25f0f 100644 --- a/lib/teiserver_web/controllers/admin/match_controller.ex +++ b/lib/teiserver_web/controllers/admin/match_controller.ex @@ -239,8 +239,11 @@ defmodule TeiserverWeb.Admin.MatchController do match.team_count > 2 -> if match.team_size > 1, do: "Team FFA", else: "FFA" + match.team_count == 2 -> + if match.team_size > 4, do: "Big Team", else: "Small Team" + true -> - "Team" + "Big Team" end partied_players = diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index ace9e1b20..d79022f79 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -22,7 +22,7 @@ defmodule TeiserverWeb.API.SpadsController do }) do actual_type = case type do - "TeamFFA" -> "Team" + "TeamFFA" -> "Big Team" # Team FFA uses Big Team rating v -> v end @@ -160,7 +160,8 @@ defmodule TeiserverWeb.API.SpadsController do rating_type = cond do total_players == 2 -> "Duel" - team_count == 2 -> "Team" + team_count == 2 and total_players <= 8 -> "Small Team" + team_count == 2 and total_players > 8 -> "Big Team" total_players == team_count -> "FFA" true -> "Team FFA" end diff --git a/lib/teiserver_web/controllers/report/rating_controller.ex b/lib/teiserver_web/controllers/report/rating_controller.ex index 873adce78..5e5c58801 100644 --- a/lib/teiserver_web/controllers/report/rating_controller.ex +++ b/lib/teiserver_web/controllers/report/rating_controller.ex @@ -55,7 +55,7 @@ defmodule TeiserverWeb.Report.RatingController do rating_type = cond do Enum.count(player_ids) == 2 -> "Duel" - true -> "Team" + true -> "Big Team" # Should probably get rating based on team size instad end rating_lookup = diff --git a/lib/teiserver_web/live/moderation/report_user/index.ex b/lib/teiserver_web/live/moderation/report_user/index.ex index 14fc43f17..18ee41a84 100644 --- a/lib/teiserver_web/live/moderation/report_user/index.ex +++ b/lib/teiserver_web/live/moderation/report_user/index.ex @@ -191,7 +191,7 @@ defmodule TeiserverWeb.Moderation.ReportUserLive.Index do |> Enum.map(fn match -> label = case match.game_type do - "Team" -> "#{match.team_size} vs #{match.team_size} on #{match.map}" + type when type in ["Small Team", "Big Team"] -> "#{match.team_size} vs #{match.team_size} on #{match.map}" "FFA" -> "#{match.team_count} way FFA on #{match.map}" v -> v end diff --git a/lib/teiserver_web/templates/admin/match/search.html.heex b/lib/teiserver_web/templates/admin/match/search.html.heex index e2d9672bb..83dedb8ba 100644 --- a/lib/teiserver_web/templates/admin/match/search.html.heex +++ b/lib/teiserver_web/templates/admin/match/search.html.heex @@ -78,7 +78,8 @@ enumerable: [ %{id: "", name: "Any", icon: "fa-solid fa-square", colour: "#AA0000"}, %{id: "Duel", name: "Duel", icon: "fa-solid fa-square", colour: "#AA0000"}, - %{id: "Team", name: "Team", icon: "fa-solid fa-square", colour: "#AA0000"}, + %{id: "Small Team", name: "Small Team", icon: "fa-solid fa-square", colour: "#AA0000"}, + %{id: "Big Team", name: "Big Team", icon: "fa-solid fa-square", colour: "#AA0000"}, %{id: "FFA", name: "FFA", icon: "fa-solid fa-square", colour: "#AA0000"}, %{ id: "Team FFA", diff --git a/lib/teiserver_web/templates/admin/user/ratings.html.heex b/lib/teiserver_web/templates/admin/user/ratings.html.heex index a95fa34b2..0816942b5 100644 --- a/lib/teiserver_web/templates/admin/user/ratings.html.heex +++ b/lib/teiserver_web/templates/admin/user/ratings.html.heex @@ -99,7 +99,7 @@ Game - <%= if @filter == "Team" do %> + <%= if @filter in ["Small Team", "Big Team"] do %> Play <% end %> Players @@ -122,7 +122,7 @@ end {exit_status, play_percentage} = - if log.match.game_type == "Team" do + if log.match.game_type in ["Small Team", "Big Team"] do exit_status = Teiserver.Battle.MatchLib.calculate_exit_status( log.match_membership.left_after, @@ -142,7 +142,7 @@ <%= if log.match do %> <%= log.match.map %> - <%= if @filter == "Team" do %> + <%= if @filter in ["Small Team", "Big Team"] do %> <%= case exit_status do %> <% :stayed -> %> diff --git a/lib/teiserver_web/templates/report/report/open_skill.html.heex b/lib/teiserver_web/templates/report/report/open_skill.html.heex index 5f617a269..df5d97012 100644 --- a/lib/teiserver_web/templates/report/report/open_skill.html.heex +++ b/lib/teiserver_web/templates/report/report/open_skill.html.heex @@ -58,7 +58,8 @@ :report, :rating_type, [ - "Team", + "Small Team", + "Big Team", "Partied Team", "Duel", "FFA", diff --git a/lib/teiserver_web/templates/report/report/user_age.html.heex b/lib/teiserver_web/templates/report/report/user_age.html.heex index b8de1c1ca..d78020af9 100644 --- a/lib/teiserver_web/templates/report/report/user_age.html.heex +++ b/lib/teiserver_web/templates/report/report/user_age.html.heex @@ -74,7 +74,8 @@ [ "Any", "Duel", - "Team", + "Small Team", + "Big Team", "FFA", "Raptors", "Scavengers", diff --git a/test/teiserver/account/accolade_bot_test.exs b/test/teiserver/account/accolade_bot_test.exs index 94bca8f5e..e1c28f77f 100644 --- a/test/teiserver/account/accolade_bot_test.exs +++ b/test/teiserver/account/accolade_bot_test.exs @@ -29,7 +29,7 @@ defmodule Teiserver.Account.AccoladeBotTest do team_count: 2, team_size: 2, passworded: false, - game_type: "Team", + game_type: "Small Team", founder_id: host.id, founder_name: host.name, server_uuid: "123", From ef4ba8d7ada1733e04bdae5a7ca9bb01bbf05b60 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 15:10:09 +0200 Subject: [PATCH 03/22] Ignore unfinished matches, rerate all team games --- lib/teiserver/mix_tasks/team_rating.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index 272a659fc..dc7386d67 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -20,12 +20,15 @@ defmodule Mix.Tasks.Teiserver.Teamrating do _ -> false end + rating_type_id = rating_type_name_lookup()["Team"] + reset_player_ratings(rating_type_id) + Logger.debug("Starting to process small team games..") process_small_team_games() Logger.debug("Finished processing small team games") Logger.debug("Starting to process big team games") - process_big_team_games(rate) + process_big_team_games(true) Logger.debug("Finished processing big team games") end @@ -36,6 +39,8 @@ defmodule Mix.Tasks.Teiserver.Teamrating do search: [ server_uuid_not_nil: true, game_type: "Team", + has_finished: true, + processed: true, team_size_less_than: 5 ], limit: :infinity, @@ -66,6 +71,8 @@ defmodule Mix.Tasks.Teiserver.Teamrating do search: [ server_uuid_not_nil: true, game_type: "Team", + has_finished: true, + processed: true, team_size_greater_than: 4 ], limit: :infinity From 72c829b45c38b7204095127d5c977fd340c404e1 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 15:11:45 +0200 Subject: [PATCH 04/22] Fix --- lib/teiserver/mix_tasks/team_rating.ex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index dc7386d67..231aabcac 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -8,7 +8,6 @@ defmodule Mix.Tasks.Teiserver.Teamrating do use Mix.Task alias Teiserver.Battle - require Logger @spec run(list()) :: :ok @@ -20,8 +19,8 @@ defmodule Mix.Tasks.Teiserver.Teamrating do _ -> false end - rating_type_id = rating_type_name_lookup()["Team"] - reset_player_ratings(rating_type_id) + rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] + Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) Logger.debug("Starting to process small team games..") process_small_team_games() From ff3c465ff1417d1727d02c06cc92e9a805e72f84 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 15:57:12 +0200 Subject: [PATCH 05/22] Fix again --- lib/teiserver/game/libs/match_rating_lib.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teiserver/game/libs/match_rating_lib.ex b/lib/teiserver/game/libs/match_rating_lib.ex index 8e9421bb6..da3065feb 100644 --- a/lib/teiserver/game/libs/match_rating_lib.ex +++ b/lib/teiserver/game/libs/match_rating_lib.ex @@ -10,7 +10,7 @@ defmodule Teiserver.Game.MatchRatingLib do alias Teiserver.Battle.{BalanceLib, MatchLib} require Logger - @rated_match_types ["Small Team", "Big Team", "Duel", "FFA", "Team FFA", "Partied Team"] + @rated_match_types ["Small Team", "Big Team", "Duel", "Team", "FFA", "Team FFA", "Partied Team"] @spec rating_type_list() :: [String.t()] def rating_type_list() do From 93a319783761f8f452d205246a1421978451fcf9 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 16:14:45 +0200 Subject: [PATCH 06/22] Add preload to big team matches --- lib/teiserver/mix_tasks/team_rating.ex | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index 231aabcac..6ef4a7498 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -19,12 +19,12 @@ defmodule Mix.Tasks.Teiserver.Teamrating do _ -> false end - rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] - Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) + #rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] + #Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) - Logger.debug("Starting to process small team games..") - process_small_team_games() - Logger.debug("Finished processing small team games") + #Logger.debug("Starting to process small team games..") + #process_small_team_games() + #Logger.debug("Finished processing small team games") Logger.debug("Starting to process big team games") process_big_team_games(true) @@ -74,7 +74,8 @@ defmodule Mix.Tasks.Teiserver.Teamrating do processed: true, team_size_greater_than: 4 ], - limit: :infinity + limit: :infinity, + preload: [:members] ) Logger.debug("Found #{Enum.count(big_team_matches)} big team game matches") @@ -89,10 +90,8 @@ defmodule Mix.Tasks.Teiserver.Teamrating do game_type: "Big Team" }) - if rate_big_games do - Logger.debug("RATING") - Teiserver.rate_match(match) - end + Logger.debug("RATING") + Teiserver.rate_match(match) end) end) end From e6d8d1c5a281dbeb8cc6d4f02c3d92ed3fee50bc Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 16:26:24 +0200 Subject: [PATCH 07/22] Process in batches of 10k --- lib/teiserver/mix_tasks/team_rating.ex | 42 +++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index 6ef4a7498..7b7433954 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -27,7 +27,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do #Logger.debug("Finished processing small team games") Logger.debug("Starting to process big team games") - process_big_team_games(true) + process_big_team_games(0) Logger.debug("Finished processing big team games") end @@ -63,8 +63,9 @@ defmodule Mix.Tasks.Teiserver.Teamrating do end) end - defp process_big_team_games(rate_big_games) do - # Get all big team matches + defp process_big_team_games(offset) do + batch_size = 10_000 + big_team_matches = Battle.list_matches( search: [ @@ -74,25 +75,32 @@ defmodule Mix.Tasks.Teiserver.Teamrating do processed: true, team_size_greater_than: 4 ], - limit: :infinity, + limit: batch_size, + offset: offset, preload: [:members] ) - Logger.debug("Found #{Enum.count(big_team_matches)} big team game matches") + match_count = Enum.count(big_team_matches) + Logger.debug("Found #{match_count} big team game matches") - # For big team games only change game type - big_team_matches - |> Enum.chunk_every(50) - |> Enum.each(fn chunk -> - chunk - |> Enum.each(fn match -> - Battle.update_match(match, %{ - game_type: "Big Team" - }) + if match_count > 0 do + big_team_matches + |> Enum.chunk_every(50) + |> Enum.each(fn chunk -> + chunk + |> Enum.each(fn match -> + Battle.update_match(match, %{ + game_type: "Big Team" + }) - Logger.debug("RATING") - Teiserver.rate_match(match) + Logger.debug("RATING") + Teiserver.rate_match(match) + end) end) - end) + + # Fetch and process the next batch + process_big_team_games(offset + batch_size) + end end + end From e2f1c365e6a2994bb02f185992cd67195fffe944 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 16:27:25 +0200 Subject: [PATCH 08/22] Increase to 50k --- lib/teiserver/mix_tasks/team_rating.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index 7b7433954..a3c941bfa 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -64,7 +64,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do end defp process_big_team_games(offset) do - batch_size = 10_000 + batch_size = 50_000 big_team_matches = Battle.list_matches( From 6f81aa210b70687c3cdbbf3e8b8eda319bacead1 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 16:34:59 +0200 Subject: [PATCH 09/22] DB reset --- lib/teiserver/mix_tasks/team_rating.ex | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index a3c941bfa..a1a7c2b22 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -14,20 +14,15 @@ defmodule Mix.Tasks.Teiserver.Teamrating do def run(args) do Application.ensure_all_started(:teiserver) - rate = case args do - ["true"] -> true - _ -> false - end - - #rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] - #Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) + rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] + Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) - #Logger.debug("Starting to process small team games..") - #process_small_team_games() - #Logger.debug("Finished processing small team games") + Logger.debug("Starting to process small team games..") + process_small_team_games() + Logger.debug("Finished processing small team games") Logger.debug("Starting to process big team games") - process_big_team_games(0) + process_big_team_games(0, 0) Logger.debug("Finished processing big team games") end @@ -63,7 +58,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do end) end - defp process_big_team_games(offset) do + defp process_big_team_games(offset, i) do batch_size = 50_000 big_team_matches = @@ -81,7 +76,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do ) match_count = Enum.count(big_team_matches) - Logger.debug("Found #{match_count} big team game matches") + Logger.debug("Batch #{i} - Found #{match_count} big team game matches") if match_count > 0 do big_team_matches @@ -99,7 +94,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do end) # Fetch and process the next batch - process_big_team_games(offset + batch_size) + process_big_team_games(offset + batch_size, i+1) end end From aedaf0d1a0a94279004b7f2d7b410f5a19a9fe46 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 18:02:04 +0200 Subject: [PATCH 10/22] Requery fix --- lib/teiserver/mix_tasks/team_rating.ex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index a1a7c2b22..c4320d07c 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -53,7 +53,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do game_type: "Small Team" }) - Teiserver.rate_match(match) + Teiserver.rate_match(match.id) end) end) end @@ -87,9 +87,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do Battle.update_match(match, %{ game_type: "Big Team" }) - - Logger.debug("RATING") - Teiserver.rate_match(match) + Teiserver.rate_match(match.id) end) end) From 99d83f23cbc806b5f1f9f1595a895a547019be44 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 19:52:57 +0200 Subject: [PATCH 11/22] Rerate chronologically --- lib/teiserver/mix_tasks/team_rating.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index c4320d07c..a8169bb6a 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -32,11 +32,12 @@ defmodule Mix.Tasks.Teiserver.Teamrating do Battle.list_matches( search: [ server_uuid_not_nil: true, - game_type: "Team", + game_type_in: ["Team", "Small Team"], has_finished: true, processed: true, team_size_less_than: 5 ], + order_by: "Oldest first", limit: :infinity, preload: [:members] ) @@ -65,11 +66,12 @@ defmodule Mix.Tasks.Teiserver.Teamrating do Battle.list_matches( search: [ server_uuid_not_nil: true, - game_type: "Team", + game_type_in: ["Team", "Small Team"], has_finished: true, processed: true, team_size_greater_than: 4 ], + order_by: "Oldest first", limit: batch_size, offset: offset, preload: [:members] From e6607d92710b23df61dfb0faffaff744ae76da66 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 26 May 2024 19:53:38 +0200 Subject: [PATCH 12/22] Bugfix --- lib/teiserver/mix_tasks/team_rating.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex index a8169bb6a..8b03b82bf 100644 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ b/lib/teiserver/mix_tasks/team_rating.ex @@ -66,7 +66,7 @@ defmodule Mix.Tasks.Teiserver.Teamrating do Battle.list_matches( search: [ server_uuid_not_nil: true, - game_type_in: ["Team", "Small Team"], + game_type_in: ["Team", "Big Team"], has_finished: true, processed: true, team_size_greater_than: 4 From 6c8b6140351ddeef83e0a4604afdef45c5a344fd Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:47:04 +0200 Subject: [PATCH 13/22] Send correct team rating to SPADS --- .../controllers/api/spads_controller.ex | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index d79022f79..f7188e597 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -19,16 +19,20 @@ defmodule TeiserverWeb.API.SpadsController do def get_rating(conn, %{ "target_id" => target_id_str, "type" => type - }) do + } + ) do + + target_id = int_parse(target_id_str) + lobby = get_member_lobby(target_id) + host_ip = get_lobby_host_ip(lobby) + actual_type = case type do + "Team" -> get_team_subtype(lobby) "TeamFFA" -> "Big Team" # Team FFA uses Big Team rating v -> v end - target_id = int_parse(target_id_str) - host_ip = get_member_of_lobby_host_ip(target_id) - conn_ip = conn |> Teiserver.Logging.LoggingPlug.get_ip_from_conn() @@ -217,13 +221,13 @@ defmodule TeiserverWeb.API.SpadsController do def get_member_of_lobby_host_ip(nil), do: nil - def get_member_of_lobby_host_ip(userid) do + def get_member_lobby(userid) do case Account.get_client_by_id(userid) do nil -> nil client -> - get_lobby_host_ip(client.lobby_id) + Battle.get_lobby(userid) end end @@ -239,4 +243,28 @@ defmodule TeiserverWeb.API.SpadsController do host.ip end end + + def get_lobby_host_ip(nil), do: "Big Team" + + defp get_team_subtype(lobby) do + teams = + lobby.member_list + |> Account.list_clients() + |> Enum.filter(fn c -> c.player == true end) + |> Enum.group_by(fn c -> c.team_number end) + + max_team_size = + case Enum.map(teams, fn {_, team} -> Enum.count(team) end) do + [] -> + 0 + + counts -> + Enum.max(counts) + end + + cond do + Enum.count(teams) == 2 and max_team_size <= 4 -> "Small Team" # 2v2, 3v3, 4v4 + true -> "Big Team" + end + end end From 3a92dcb93dfe4bbbe64b7e2b354521e42f3c911a Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:15:56 +0200 Subject: [PATCH 14/22] Send correct team rating to SPADS --- .../controllers/api/spads_controller.ex | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index f7188e597..70d5a6ecb 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -24,7 +24,10 @@ defmodule TeiserverWeb.API.SpadsController do target_id = int_parse(target_id_str) lobby = get_member_lobby(target_id) - host_ip = get_lobby_host_ip(lobby) + host_ip = case lobby do + nil -> nil + _ -> Account.get_client_by_id(lobby.founder_id).ip + end actual_type = case type do @@ -219,32 +222,20 @@ defmodule TeiserverWeb.API.SpadsController do end end - def get_member_of_lobby_host_ip(nil), do: nil + defp get_member_lobby(nil), do: nil - def get_member_lobby(userid) do + @spec get_member_lobby(non_neg_integer()) :: T.lobby() | nil + defp get_member_lobby(userid) do case Account.get_client_by_id(userid) do nil -> nil client -> - Battle.get_lobby(userid) - end - end - - def get_lobby_host_ip(nil), do: nil - - def get_lobby_host_ip(lobby_id) do - case Battle.get_lobby(lobby_id) do - nil -> - nil - - lobby -> - host = Account.get_client_by_id(lobby.founder_id) - host.ip + Battle.get_lobby(client.lobby_id) end end - def get_lobby_host_ip(nil), do: "Big Team" + defp get_team_subtype(nil), do: "Big Team" defp get_team_subtype(lobby) do teams = From 49504cbd6f97b7a03dceb2920c1a2a52331d8520 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:15:38 +0200 Subject: [PATCH 15/22] Fix --- lib/teiserver_web/controllers/api/spads_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index 70d5a6ecb..7e20fcdbb 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -239,7 +239,7 @@ defmodule TeiserverWeb.API.SpadsController do defp get_team_subtype(lobby) do teams = - lobby.member_list + lobby.players |> Account.list_clients() |> Enum.filter(fn c -> c.player == true end) |> Enum.group_by(fn c -> c.team_number end) From d8305a4994e21fec66260d0fe1d0d7b5a1b19167 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:07:35 +0200 Subject: [PATCH 16/22] Move all game type logic to MatchLib.game_type --- lib/teiserver/battle/libs/match_lib.ex | 37 ++++++++---------- lib/teiserver/battle/schemas/match.ex | 2 +- lib/teiserver/coordinator/consul_server.ex | 5 +-- lib/teiserver/game/libs/match_rating_lib.ex | 1 + lib/teiserver/game/servers/balancer_server.ex | 38 +++++++------------ lib/teiserver/mix_tasks/fake_data.ex | 7 +--- .../controllers/admin/match_controller.ex | 15 +------- .../controllers/api/spads_controller.ex | 25 +++++------- 8 files changed, 45 insertions(+), 85 deletions(-) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index d6a18be81..23dd8d846 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -12,39 +12,30 @@ defmodule Teiserver.Battle.MatchLib do @spec colours :: atom def colours, do: :success2 - @spec game_type(T.lobby(), map()) :: <<_::24, _::_*8>> - def game_type(lobby, teams) do - bots = Battle.get_bots(lobby.id) + def game_type(team_size, team_count) do + game_type(team_size, team_count, %{}) + end + def game_type(team_size, team_count, bots) do bot_names = bots |> Map.keys() |> Enum.join(" ") - # It is possible for it to be purely bots v bots which will make it appear to be empty teams - # this would cause an error with Enum.max, hence the case statement - max_team_size = - case Enum.map(teams, fn {_, team} -> Enum.count(team) end) do - [] -> - 0 - - counts -> - Enum.max(counts) - end - cond do String.contains?(bot_names, "Scavenger") -> "Scavengers" String.contains?(bot_names, "Chicken") -> "Raptors" String.contains?(bot_names, "Raptor") -> "Raptors" Enum.empty?(bots) == false -> "Bots" - Enum.count(teams) == 2 and max_team_size == 1 -> "Duel" - Enum.count(teams) == 2 and max_team_size <= 4 -> "Small Team" # 2v2, 3v3, 4v4 - Enum.count(teams) == 2 and max_team_size > 4 -> "Big Team" # 5v5, 6v6, 7v7, 8v8 - max_team_size == 1 -> "FFA" + team_count == 2 and team_size == 1 -> "Duel" + team_count == 2 and team_size <= 5 -> "Small Team" # 2v2, 3v3, 4v4, 5v5 + team_count == 2 and team_size > 5 -> "Big Team" # 6v6, 7v7, 8v8 + team_size == 1 -> "FFA" true -> "Team FFA" end end + def list_game_types() do [ "Duel", @@ -88,7 +79,9 @@ defmodule Teiserver.Battle.MatchLib do |> Enum.group_by(fn c -> c.team_number end) if teams != %{} do - the_game_type = game_type(lobby, teams) + team_count = Enum.count(teams) + team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end) + game_type = game_type(team_size, team_count, bots) match = %{ uuid: match_uuid, @@ -96,10 +89,10 @@ defmodule Teiserver.Battle.MatchLib do map: lobby.map_name, data: nil, tags: modoptions, - team_count: Enum.count(teams), - team_size: Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end)), + team_count: team_count, + team_size: team_size, passworded: lobby.passworded, - game_type: the_game_type, + game_type: game_type, founder_id: lobby.founder_id, bots: bots, queue_id: queue_id, diff --git a/lib/teiserver/battle/schemas/match.ex b/lib/teiserver/battle/schemas/match.ex index 722d9d2fc..a18dfefab 100644 --- a/lib/teiserver/battle/schemas/match.ex +++ b/lib/teiserver/battle/schemas/match.ex @@ -14,7 +14,7 @@ defmodule Teiserver.Battle.Match do field :team_size, :integer field :passworded, :boolean field :processed, :boolean, default: false - # Scavengers, Raptors, Bots, Duel, Team, FFA, Team FFA + # Scavengers, Raptors, Bots, Duel, Small Team, Big Team, FFA, Team FFA field :game_type, :string belongs_to :founder, Teiserver.Account.User diff --git a/lib/teiserver/coordinator/consul_server.ex b/lib/teiserver/coordinator/consul_server.ex index 1a18c6574..b543c6b4f 100644 --- a/lib/teiserver/coordinator/consul_server.ex +++ b/lib/teiserver/coordinator/consul_server.ex @@ -21,7 +21,7 @@ defmodule Teiserver.Coordinator.ConsulServer do alias Teiserver.Lobby.{ChatLib} import Teiserver.Helper.NumberHelper, only: [int_parse: 1] alias Phoenix.PubSub - alias Teiserver.Battle.BalanceLib + alias Teiserver.Battle.{BalanceLib, MatchLib} alias Teiserver.Data.Types, as: T alias Teiserver.Coordinator.{ConsulCommands, CoordinatorLib, SpadsParser} @@ -834,10 +834,9 @@ defmodule Teiserver.Coordinator.ConsulServer do @spec user_allowed_to_play?(T.user(), T.client(), map()) :: boolean() defp user_allowed_to_play?(user, client, state) do player_list = list_players(state) + rating_type = MatchLib.game_type(state.host_teamsize, state.host_teamcount) {player_rating, player_uncertainty} = - # TODO FIX THIS BUG - # Teiserver.Battle.MatchLib.game_type/2 maybe to check for game type to get ratings for? BalanceLib.get_user_rating_value_uncertainty_pair(user.id, "Big Team") player_rating = max(player_rating, 1) diff --git a/lib/teiserver/game/libs/match_rating_lib.ex b/lib/teiserver/game/libs/match_rating_lib.ex index da3065feb..1b6be9c0e 100644 --- a/lib/teiserver/game/libs/match_rating_lib.ex +++ b/lib/teiserver/game/libs/match_rating_lib.ex @@ -11,6 +11,7 @@ defmodule Teiserver.Game.MatchRatingLib do require Logger @rated_match_types ["Small Team", "Big Team", "Duel", "Team", "FFA", "Team FFA", "Partied Team"] + # TODO Remove "Team" from here once the split is done @spec rating_type_list() :: [String.t()] def rating_type_list() do diff --git a/lib/teiserver/game/servers/balancer_server.ex b/lib/teiserver/game/servers/balancer_server.ex index e215259f8..8b855b8ac 100644 --- a/lib/teiserver/game/servers/balancer_server.ex +++ b/lib/teiserver/game/servers/balancer_server.ex @@ -4,6 +4,7 @@ defmodule Teiserver.Game.BalancerServer do alias Teiserver.Data.Types, as: T alias Teiserver.Battle.BalanceLib alias Teiserver.{Battle, Coordinator} + alias Teiserver.Battle.MatchLib @tick_interval 2_000 @@ -161,31 +162,20 @@ defmodule Teiserver.Game.BalancerServer do @spec do_make_balance(non_neg_integer(), [T.client()], List.t()) :: map() defp do_make_balance(team_count, players, opts) do - player_count = Enum.count(players) - - rating_type = - cond do - player_count == 2 -> - "Duel" - - team_count > 2 -> - if player_count > team_count, do: "Big Team", else: "FFA" - - team_count == 2 -> - if player_count > 8, do: "Big Team", else: "Small Team" - - true -> - "Big Team" - end + teams = + players + |> Enum.group_by(fn c -> c.team_number end) + team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end) + game_type = MatchLib.game_type(team_size, team_count) if opts[:allow_groups] do - party_result = make_grouped_balance(team_count, players, rating_type, opts) + party_result = make_grouped_balance(team_count, players, game_type, opts) if party_result.deviation > opts[:max_deviation] do make_solo_balance( team_count, players, - rating_type, + game_type, [ "Tried grouped mode, got a deviation of #{party_result.deviation} and reverted to solo mode" ], @@ -195,12 +185,12 @@ defmodule Teiserver.Game.BalancerServer do party_result end else - make_solo_balance(team_count, players, rating_type, [], opts) + make_solo_balance(team_count, players, game_type, [], opts) end end @spec make_grouped_balance(non_neg_integer(), [T.client()], String.t(), list()) :: map() - defp make_grouped_balance(team_count, players, rating_type, opts) do + defp make_grouped_balance(team_count, players, game_type, opts) do # Group players into parties partied_players = players @@ -216,14 +206,14 @@ defmodule Teiserver.Game.BalancerServer do |> Enum.map(fn userid -> %{ userid => - BalanceLib.get_user_rating_rank(userid, rating_type, opts[:fuzz_multiplier]) + BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) } end) {_party_id, player_id_list} -> player_id_list |> Map.new(fn userid -> - {userid, BalanceLib.get_user_rating_rank(userid, rating_type, opts[:fuzz_multiplier])} + {userid, BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier])} end) end) |> List.flatten() @@ -234,13 +224,13 @@ defmodule Teiserver.Game.BalancerServer do @spec make_solo_balance(non_neg_integer(), [T.client()], String.t(), [String.t()], list()) :: map() - defp make_solo_balance(team_count, players, rating_type, initial_logs, opts) do + defp make_solo_balance(team_count, players, game_type, initial_logs, opts) do groups = players |> Enum.map(fn %{userid: userid} -> %{ userid => - BalanceLib.get_user_rating_rank(userid, rating_type, opts[:fuzz_multiplier]) + BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) } end) diff --git a/lib/teiserver/mix_tasks/fake_data.ex b/lib/teiserver/mix_tasks/fake_data.ex index e217e99df..982b5f33e 100644 --- a/lib/teiserver/mix_tasks/fake_data.ex +++ b/lib/teiserver/mix_tasks/fake_data.ex @@ -7,6 +7,7 @@ defmodule Mix.Tasks.Teiserver.Fakedata do alias Teiserver.{Account, Logging, Battle, Moderation} alias Teiserver.Helper.StylingHelper + alias Teiserver.Battle.MatchLib require Logger @settings %{ @@ -331,11 +332,7 @@ defmodule Mix.Tasks.Teiserver.Fakedata do team1 = shuffled_users |> Enum.take(team_size) team2 = shuffled_users |> Enum.reverse() |> Enum.take(team_size) - game_type = cond do - team_size == 1 -> "Duel" - team_size <= 4 -> "Small Team" - true -> "Big Team" - end + game_type = MatchLib.game_type(team_size, 2) team1_score = team1 diff --git a/lib/teiserver_web/controllers/admin/match_controller.ex b/lib/teiserver_web/controllers/admin/match_controller.ex index 7a214a642..7da660709 100644 --- a/lib/teiserver_web/controllers/admin/match_controller.ex +++ b/lib/teiserver_web/controllers/admin/match_controller.ex @@ -231,20 +231,7 @@ defmodule TeiserverWeb.Admin.MatchController do end defp generate_new_balance_data(match) do - rating_type = - cond do - match.team_size == 1 -> - "Duel" - - match.team_count > 2 -> - if match.team_size > 1, do: "Team FFA", else: "FFA" - - match.team_count == 2 -> - if match.team_size > 4, do: "Big Team", else: "Small Team" - - true -> - "Big Team" - end + rating_type = MatchLib.game_type(match.team_size, match.team_count) partied_players = match.members diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index 7e20fcdbb..98b2852fb 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -2,7 +2,7 @@ defmodule TeiserverWeb.API.SpadsController do use TeiserverWeb, :controller alias Teiserver.Config alias Teiserver.{Account, Coordinator, Battle} - alias Teiserver.Battle.BalanceLib + alias Teiserver.Battle.{BalanceLib, MatchLib} import Teiserver.Helper.NumberHelper, only: [int_parse: 1] require Logger @@ -154,24 +154,17 @@ defmodule TeiserverWeb.API.SpadsController do if balance_result do # Get some counts for later - total_players = - balance_result.team_sizes - |> Map.values() - |> Enum.sum() - team_count = balance_result.team_sizes |> Enum.count() - # Calculate the rating type - rating_type = - cond do - total_players == 2 -> "Duel" - team_count == 2 and total_players <= 8 -> "Small Team" - team_count == 2 and total_players > 8 -> "Big Team" - total_players == team_count -> "FFA" - true -> "Team FFA" - end + team_size = + balance_result.team_sizes + |> Map.values() + |> Enum.max() + + # Get the rating type + rating_type = MatchLib.game_type(team_size, team_count) # Temporary solution until Team FFA ratings are fixed rating_type = @@ -254,7 +247,7 @@ defmodule TeiserverWeb.API.SpadsController do end cond do - Enum.count(teams) == 2 and max_team_size <= 4 -> "Small Team" # 2v2, 3v3, 4v4 + Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team" # 2v2, 3v3, 4v4, 5v5 true -> "Big Team" end end From f2b76e7beee22876c08bb93e7a6608f22ef13e4c Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 18:25:18 +0200 Subject: [PATCH 17/22] Cleanup and formatting --- lib/teiserver/battle/libs/match_lib.ex | 16 ++- lib/teiserver/coordinator/consul_server.ex | 2 +- lib/teiserver/game/servers/balancer_server.ex | 7 +- lib/teiserver/libs/test_lib.ex | 1 - lib/teiserver/mix_tasks/team_rating.ex | 101 ------------------ .../controllers/api/spads_controller.ex | 20 ++-- .../live/moderation/report_user/index.ex | 11 +- .../templates/admin/match/search.html.heex | 14 ++- 8 files changed, 46 insertions(+), 126 deletions(-) delete mode 100644 lib/teiserver/mix_tasks/team_rating.ex diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index 93c86d52d..9e26f1a0f 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -35,7 +35,6 @@ defmodule Teiserver.Battle.MatchLib do end end - def list_game_types() do [ "Duel", @@ -137,10 +136,17 @@ defmodule Teiserver.Battle.MatchLib do def make_match_name(match) do case match.game_type do - "Duel" -> "Duel on #{match.map}" - type when type in ["Small Team", "Big Team"] -> "#{match.team_size}v#{match.team_size} on #{match.map}" - "FFA" -> "#{match.team_count} way FFA on #{match.map}" - t -> "#{t} game on #{match.map}" + "Duel" -> + "Duel on #{match.map}" + + type when type in ["Small Team", "Big Team"] -> + "#{match.team_size}v#{match.team_size} on #{match.map}" + + "FFA" -> + "#{match.team_count} way FFA on #{match.map}" + + t -> + "#{t} game on #{match.map}" end end diff --git a/lib/teiserver/coordinator/consul_server.ex b/lib/teiserver/coordinator/consul_server.ex index a0c700001..715050fc8 100644 --- a/lib/teiserver/coordinator/consul_server.ex +++ b/lib/teiserver/coordinator/consul_server.ex @@ -838,7 +838,7 @@ defmodule Teiserver.Coordinator.ConsulServer do rating_type = MatchLib.game_type(state.host_teamsize, state.host_teamcount) {player_rating, player_uncertainty} = - BalanceLib.get_user_rating_value_uncertainty_pair(user.id, "Big Team") + BalanceLib.get_user_rating_value_uncertainty_pair(user.id, rating_type) player_rating = max(player_rating, 1) avoid_status = Account.check_avoid_status(user.id, player_list) diff --git a/lib/teiserver/game/servers/balancer_server.ex b/lib/teiserver/game/servers/balancer_server.ex index 8b855b8ac..dcf54027e 100644 --- a/lib/teiserver/game/servers/balancer_server.ex +++ b/lib/teiserver/game/servers/balancer_server.ex @@ -165,6 +165,7 @@ defmodule Teiserver.Game.BalancerServer do teams = players |> Enum.group_by(fn c -> c.team_number end) + team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end) game_type = MatchLib.game_type(team_size, team_count) @@ -205,8 +206,7 @@ defmodule Teiserver.Game.BalancerServer do player_id_list |> Enum.map(fn userid -> %{ - userid => - BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) + userid => BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) } end) @@ -229,8 +229,7 @@ defmodule Teiserver.Game.BalancerServer do players |> Enum.map(fn %{userid: userid} -> %{ - userid => - BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) + userid => BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier]) } end) diff --git a/lib/teiserver/libs/test_lib.ex b/lib/teiserver/libs/test_lib.ex index 70c070d3d..de170a19b 100644 --- a/lib/teiserver/libs/test_lib.ex +++ b/lib/teiserver/libs/test_lib.ex @@ -1,7 +1,6 @@ defmodule Teiserver.TeiserverTestLib do @moduledoc false alias Teiserver.{Client, CacheUser, Account} - alias Teiserver.Lobby.LobbyLib alias Teiserver.Account.AccoladeLib alias Teiserver.Protocols.TachyonLib alias Teiserver.Coordinator.CoordinatorServer diff --git a/lib/teiserver/mix_tasks/team_rating.ex b/lib/teiserver/mix_tasks/team_rating.ex deleted file mode 100644 index 8b03b82bf..000000000 --- a/lib/teiserver/mix_tasks/team_rating.ex +++ /dev/null @@ -1,101 +0,0 @@ -defmodule Mix.Tasks.Teiserver.Teamrating do - @moduledoc """ - Run with mix teiserver.teamrating - Goes through every existing 'Team' rating and sorts it into either 'Small Team' or 'Big Team' rating category based on team size. - Recalculates 'Small Team' and 'Big Team' ratings for affected players. - """ - - use Mix.Task - - alias Teiserver.Battle - require Logger - - @spec run(list()) :: :ok - def run(args) do - Application.ensure_all_started(:teiserver) - - rating_type_id = Teiserver.Game.MatchRatingLib.rating_type_name_lookup()["Team"] - Teiserver.Game.MatchRatingLib.reset_player_ratings(rating_type_id) - - Logger.debug("Starting to process small team games..") - process_small_team_games() - Logger.debug("Finished processing small team games") - - Logger.debug("Starting to process big team games") - process_big_team_games(0, 0) - Logger.debug("Finished processing big team games") - end - - defp process_small_team_games() do - # Get all small team matches - small_team_matches = - Battle.list_matches( - search: [ - server_uuid_not_nil: true, - game_type_in: ["Team", "Small Team"], - has_finished: true, - processed: true, - team_size_less_than: 5 - ], - order_by: "Oldest first", - limit: :infinity, - preload: [:members] - ) - - Logger.debug("Found #{Enum.count(small_team_matches)} small team game matches") - - # For small team games change game type and update rating - small_team_matches - |> Enum.chunk_every(50) - |> Enum.each(fn chunk -> - chunk - |> Enum.each(fn match -> - Battle.update_match(match, %{ - game_type: "Small Team" - }) - - Teiserver.rate_match(match.id) - end) - end) - end - - defp process_big_team_games(offset, i) do - batch_size = 50_000 - - big_team_matches = - Battle.list_matches( - search: [ - server_uuid_not_nil: true, - game_type_in: ["Team", "Big Team"], - has_finished: true, - processed: true, - team_size_greater_than: 4 - ], - order_by: "Oldest first", - limit: batch_size, - offset: offset, - preload: [:members] - ) - - match_count = Enum.count(big_team_matches) - Logger.debug("Batch #{i} - Found #{match_count} big team game matches") - - if match_count > 0 do - big_team_matches - |> Enum.chunk_every(50) - |> Enum.each(fn chunk -> - chunk - |> Enum.each(fn match -> - Battle.update_match(match, %{ - game_type: "Big Team" - }) - Teiserver.rate_match(match.id) - end) - end) - - # Fetch and process the next batch - process_big_team_games(offset + batch_size, i+1) - end - end - -end diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index 98b2852fb..f8786fb42 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -19,20 +19,21 @@ defmodule TeiserverWeb.API.SpadsController do def get_rating(conn, %{ "target_id" => target_id_str, "type" => type - } - ) do - + }) do target_id = int_parse(target_id_str) lobby = get_member_lobby(target_id) - host_ip = case lobby do - nil -> nil - _ -> Account.get_client_by_id(lobby.founder_id).ip - end + + host_ip = + case lobby do + nil -> nil + _ -> Account.get_client_by_id(lobby.founder_id).ip + end actual_type = case type do "Team" -> get_team_subtype(lobby) - "TeamFFA" -> "Big Team" # Team FFA uses Big Team rating + # Team FFA uses Big Team rating + "TeamFFA" -> "Big Team" v -> v end @@ -247,7 +248,8 @@ defmodule TeiserverWeb.API.SpadsController do end cond do - Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team" # 2v2, 3v3, 4v4, 5v5 + # 2v2, 3v3, 4v4, 5v5 + Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team" true -> "Big Team" end end diff --git a/lib/teiserver_web/live/moderation/report_user/index.ex b/lib/teiserver_web/live/moderation/report_user/index.ex index 18ee41a84..c3d32ff6c 100644 --- a/lib/teiserver_web/live/moderation/report_user/index.ex +++ b/lib/teiserver_web/live/moderation/report_user/index.ex @@ -191,9 +191,14 @@ defmodule TeiserverWeb.Moderation.ReportUserLive.Index do |> Enum.map(fn match -> label = case match.game_type do - type when type in ["Small Team", "Big Team"] -> "#{match.team_size} vs #{match.team_size} on #{match.map}" - "FFA" -> "#{match.team_count} way FFA on #{match.map}" - v -> v + type when type in ["Small Team", "Big Team"] -> + "#{match.team_size} vs #{match.team_size} on #{match.map}" + + "FFA" -> + "#{match.team_count} way FFA on #{match.map}" + + v -> + v end time_ago = diff --git a/lib/teiserver_web/templates/admin/match/search.html.heex b/lib/teiserver_web/templates/admin/match/search.html.heex index 83dedb8ba..504bb8c52 100644 --- a/lib/teiserver_web/templates/admin/match/search.html.heex +++ b/lib/teiserver_web/templates/admin/match/search.html.heex @@ -78,8 +78,18 @@ enumerable: [ %{id: "", name: "Any", icon: "fa-solid fa-square", colour: "#AA0000"}, %{id: "Duel", name: "Duel", icon: "fa-solid fa-square", colour: "#AA0000"}, - %{id: "Small Team", name: "Small Team", icon: "fa-solid fa-square", colour: "#AA0000"}, - %{id: "Big Team", name: "Big Team", icon: "fa-solid fa-square", colour: "#AA0000"}, + %{ + id: "Small Team", + name: "Small Team", + icon: "fa-solid fa-square", + colour: "#AA0000" + }, + %{ + id: "Big Team", + name: "Big Team", + icon: "fa-solid fa-square", + colour: "#AA0000" + }, %{id: "FFA", name: "FFA", icon: "fa-solid fa-square", colour: "#AA0000"}, %{ id: "Team FFA", From 158cd00cfec917da160b9966eed515efda9097b0 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:49:15 +0200 Subject: [PATCH 18/22] mix format --- lib/teiserver/battle/libs/match_lib.ex | 6 +++-- .../controllers/report/rating_controller.ex | 7 +++--- test/teiserver/coordinator/memes_test.exs | 2 +- .../live/microblog/blog/index_live_test.exs | 24 ++++++++++++++++--- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index 9e26f1a0f..1b23b37e2 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -28,8 +28,10 @@ defmodule Teiserver.Battle.MatchLib do String.contains?(bot_names, "Raptor") -> "Raptors" Enum.empty?(bots) == false -> "Bots" team_count == 2 and team_size == 1 -> "Duel" - team_count == 2 and team_size <= 5 -> "Small Team" # 2v2, 3v3, 4v4, 5v5 - team_count == 2 and team_size > 5 -> "Big Team" # 6v6, 7v7, 8v8 + # 2v2, 3v3, 4v4, 5v5 + team_count == 2 and team_size <= 5 -> "Small Team" + # 6v6, 7v7, 8v8 + team_count == 2 and team_size > 5 -> "Big Team" team_size == 1 -> "FFA" true -> "Team FFA" end diff --git a/lib/teiserver_web/controllers/report/rating_controller.ex b/lib/teiserver_web/controllers/report/rating_controller.ex index 5e5c58801..22c8113c4 100644 --- a/lib/teiserver_web/controllers/report/rating_controller.ex +++ b/lib/teiserver_web/controllers/report/rating_controller.ex @@ -13,8 +13,8 @@ defmodule TeiserverWeb.Report.RatingController do action: {Phoenix.Controller, :action_name}, user: {Teiserver.Account.AuthLib, :current_user} - plug(:add_breadcrumb, name: 'Reports', url: '/teiserver/reports') - plug(:add_breadcrumb, name: 'Reports', url: '/teiserver/reports/ratings') + plug(:add_breadcrumb, name: ~c"Reports", url: ~c"/teiserver/reports") + plug(:add_breadcrumb, name: ~c"Reports", url: ~c"/teiserver/reports/ratings") @spec distribution_table(Plug.Conn.t(), map) :: Plug.Conn.t() def distribution_table(conn, _params) do @@ -55,7 +55,8 @@ defmodule TeiserverWeb.Report.RatingController do rating_type = cond do Enum.count(player_ids) == 2 -> "Duel" - true -> "Big Team" # Should probably get rating based on team size instad + # Should probably get rating based on team size instad + true -> "Big Team" end rating_lookup = diff --git a/test/teiserver/coordinator/memes_test.exs b/test/teiserver/coordinator/memes_test.exs index d467b1835..43a6e6b10 100644 --- a/test/teiserver/coordinator/memes_test.exs +++ b/test/teiserver/coordinator/memes_test.exs @@ -73,7 +73,7 @@ defmodule Teiserver.Coordinator.MemesTest do assert reply == %{ "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, + "lobby_id" => lobby_id, "new_values" => %{ "disabled_units" => ~w(armaap armalab armap armavp armhp armshltx armvp armamsub armasy armfhp armplat armshltxuw armsy armmg armllt armbeamer armhlt arm armdrag armclaw armguard armjuno armham armjeth armpw armrectr armrock armwar coraap coralab corap coravp corgant corhp corlab corvp corllt corfhp corsy corjuno corhllt corhlt) diff --git a/test/teiserver_web/live/microblog/blog/index_live_test.exs b/test/teiserver_web/live/microblog/blog/index_live_test.exs index f6137ea31..134451508 100644 --- a/test/teiserver_web/live/microblog/blog/index_live_test.exs +++ b/test/teiserver_web/live/microblog/blog/index_live_test.exs @@ -17,15 +17,33 @@ defmodule TeiserverWeb.Microblog.Blog.IndexLiveTest do tag2 = tag_fixture() tag3 = tag_fixture() - post1 = post_fixture(title: "Post 1 title", summary: "Post 1 line1", contents: "Post 1 line1\n\nPost 1 fold line") + post1 = + post_fixture( + title: "Post 1 title", + summary: "Post 1 line1", + contents: "Post 1 line1\n\nPost 1 fold line" + ) + _post1_tag1 = post_tag_fixture(post_id: post1.id, tag_id: tag1.id) _post1_tag2 = post_tag_fixture(post_id: post1.id, tag_id: tag2.id) - post2 = post_fixture(title: "Post 2 title", summary: "Post 2 line1", contents: "Post 2 line1\n\nPost 2 fold line") + post2 = + post_fixture( + title: "Post 2 title", + summary: "Post 2 line1", + contents: "Post 2 line1\n\nPost 2 fold line" + ) + _post2_tag1 = post_tag_fixture(post_id: post2.id, tag_id: tag1.id) _post2_tag3 = post_tag_fixture(post_id: post2.id, tag_id: tag3.id) - post3 = post_fixture(title: "Post 3 title", summary: "Post 3 line1", contents: "Post 3 line1\n\nPost 3 fold line") + post3 = + post_fixture( + title: "Post 3 title", + summary: "Post 3 line1", + contents: "Post 3 line1\n\nPost 3 fold line" + ) + _post3_tag2 = post_tag_fixture(post_id: post3.id, tag_id: tag2.id) _post3_tag3 = post_tag_fixture(post_id: post3.id, tag_id: tag3.id) From d08463347e1a46efde862ed1be33feac674c4981 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:39:57 +0200 Subject: [PATCH 19/22] Changes after review --- lib/teiserver/battle/libs/match_lib.ex | 14 ++++++++------ lib/teiserver/game/servers/balancer_server.ex | 5 ++++- lib/teiserver/libs/teiserver_configs.ex | 11 +++++++++++ .../controllers/api/spads_controller.ex | 5 +++-- .../controllers/report/rating_controller.ex | 2 +- test/teiserver/account/account_test.exs | 7 +++++++ 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index 1b23b37e2..ff1b2bc23 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -17,6 +17,8 @@ defmodule Teiserver.Battle.MatchLib do end def game_type(team_size, team_count, bots) do + max_small_team_size = Config.get_site_config_cache("lobby.Small team game limit") + bot_names = bots |> Map.keys() @@ -28,10 +30,8 @@ defmodule Teiserver.Battle.MatchLib do String.contains?(bot_names, "Raptor") -> "Raptors" Enum.empty?(bots) == false -> "Bots" team_count == 2 and team_size == 1 -> "Duel" - # 2v2, 3v3, 4v4, 5v5 - team_count == 2 and team_size <= 5 -> "Small Team" - # 6v6, 7v7, 8v8 - team_count == 2 and team_size > 5 -> "Big Team" + team_count == 2 and team_size <= max_small_team_size -> "Small Team" + team_count == 2 and team_size > max_small_team_size -> "Big Team" team_size == 1 -> "FFA" true -> "Team FFA" end @@ -80,8 +80,10 @@ defmodule Teiserver.Battle.MatchLib do |> Enum.group_by(fn c -> c.team_number end) if teams != %{} do - team_count = Enum.count(teams) - team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end) + team_count = teams |> count + team_size = teams + |> Enum.map(fn {_, t} -> (t |> count) end) + |> Enum.max(fn -> 0 end) game_type = game_type(team_size, team_count, bots) match = %{ diff --git a/lib/teiserver/game/servers/balancer_server.ex b/lib/teiserver/game/servers/balancer_server.ex index dcf54027e..a632b7801 100644 --- a/lib/teiserver/game/servers/balancer_server.ex +++ b/lib/teiserver/game/servers/balancer_server.ex @@ -166,7 +166,10 @@ defmodule Teiserver.Game.BalancerServer do players |> Enum.group_by(fn c -> c.team_number end) - team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end) + team_size = teams + |> Enum.map(fn {_, t} -> Enum.count(t) end) + |> Enum.max(fn -> 0 end) + game_type = MatchLib.game_type(team_size, team_count) if opts[:allow_groups] do diff --git a/lib/teiserver/libs/teiserver_configs.ex b/lib/teiserver/libs/teiserver_configs.ex index 44f5e1884..6baa6eba4 100644 --- a/lib/teiserver/libs/teiserver_configs.ex +++ b/lib/teiserver/libs/teiserver_configs.ex @@ -411,6 +411,17 @@ defmodule Teiserver.TeiserverConfigs do "The percentage of players who would need to avoid someone to prevent them becoming a player", default: 50 }) + + + add_site_config_type(%{ + key: "lobby.Small team game limit", + section: "Lobbies", + type: "integer", + permissions: ["Admin"], + description: + "Maximum team size to be considered as a small team game", + default: 5 + }) end defp discord_configs() do diff --git a/lib/teiserver_web/controllers/api/spads_controller.ex b/lib/teiserver_web/controllers/api/spads_controller.ex index f8786fb42..b7433c77e 100644 --- a/lib/teiserver_web/controllers/api/spads_controller.ex +++ b/lib/teiserver_web/controllers/api/spads_controller.ex @@ -232,6 +232,8 @@ defmodule TeiserverWeb.API.SpadsController do defp get_team_subtype(nil), do: "Big Team" defp get_team_subtype(lobby) do + max_small_team_size = Config.get_site_config_cache("lobby.Small team game limit") + teams = lobby.players |> Account.list_clients() @@ -248,8 +250,7 @@ defmodule TeiserverWeb.API.SpadsController do end cond do - # 2v2, 3v3, 4v4, 5v5 - Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team" + Enum.count(teams) == 2 and max_team_size <= max_small_team_size -> "Small Team" true -> "Big Team" end end diff --git a/lib/teiserver_web/controllers/report/rating_controller.ex b/lib/teiserver_web/controllers/report/rating_controller.ex index 22c8113c4..ec5ad4183 100644 --- a/lib/teiserver_web/controllers/report/rating_controller.ex +++ b/lib/teiserver_web/controllers/report/rating_controller.ex @@ -55,7 +55,7 @@ defmodule TeiserverWeb.Report.RatingController do rating_type = cond do Enum.count(player_ids) == 2 -> "Duel" - # Should probably get rating based on team size instad + # TODO Should probably get rating based on team size instad true -> "Big Team" end diff --git a/test/teiserver/account/account_test.exs b/test/teiserver/account/account_test.exs index 9351a611f..fedef5123 100644 --- a/test/teiserver/account/account_test.exs +++ b/test/teiserver/account/account_test.exs @@ -78,6 +78,13 @@ defmodule Teiserver.AccountTest do developer: "Normal" ] ) + + # Order by + Account.list_users(order_by: [{:data, "field", :asc}]) + Account.list_users(order_by: [{:data, "field", :desc}]) + + # Fallback + Account.list_users(order_by: [{:data, "field", :desc}]) end test "get_user!/1 returns the user with given id" do From c176bfb45764d195819a053538ea433941f1561e Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:42:02 +0200 Subject: [PATCH 20/22] mix format --- lib/teiserver/battle/libs/match_lib.ex | 7 +++++-- lib/teiserver/game/servers/balancer_server.ex | 3 ++- lib/teiserver/libs/teiserver_configs.ex | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index ff1b2bc23..540a154e5 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -81,9 +81,12 @@ defmodule Teiserver.Battle.MatchLib do if teams != %{} do team_count = teams |> count - team_size = teams - |> Enum.map(fn {_, t} -> (t |> count) end) + + team_size = + teams + |> Enum.map(fn {_, t} -> t |> count end) |> Enum.max(fn -> 0 end) + game_type = game_type(team_size, team_count, bots) match = %{ diff --git a/lib/teiserver/game/servers/balancer_server.ex b/lib/teiserver/game/servers/balancer_server.ex index a632b7801..c35913e15 100644 --- a/lib/teiserver/game/servers/balancer_server.ex +++ b/lib/teiserver/game/servers/balancer_server.ex @@ -166,7 +166,8 @@ defmodule Teiserver.Game.BalancerServer do players |> Enum.group_by(fn c -> c.team_number end) - team_size = teams + team_size = + teams |> Enum.map(fn {_, t} -> Enum.count(t) end) |> Enum.max(fn -> 0 end) diff --git a/lib/teiserver/libs/teiserver_configs.ex b/lib/teiserver/libs/teiserver_configs.ex index 6baa6eba4..27024b286 100644 --- a/lib/teiserver/libs/teiserver_configs.ex +++ b/lib/teiserver/libs/teiserver_configs.ex @@ -412,14 +412,12 @@ defmodule Teiserver.TeiserverConfigs do default: 50 }) - add_site_config_type(%{ key: "lobby.Small team game limit", section: "Lobbies", type: "integer", permissions: ["Admin"], - description: - "Maximum team size to be considered as a small team game", + description: "Maximum team size to be considered as a small team game", default: 5 }) end From 8919e5baa59894008d14a881db4e23f73cea860f Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:46:34 +0200 Subject: [PATCH 21/22] Forgot to add Config alias --- lib/teiserver/battle/libs/match_lib.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index 540a154e5..7c53820bf 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -1,6 +1,7 @@ defmodule Teiserver.Battle.MatchLib do @moduledoc false use TeiserverWeb, :library + alias Teiserver.Config alias Teiserver.{Battle, Account} alias Teiserver.Battle.{Match, MatchMembership} alias Teiserver.Data.Types, as: T From 6ad3bd47c8a49c288ae596b69347fe178a79f7a3 Mon Sep 17 00:00:00 2001 From: L-e-x-o-n <44340857+L-e-x-o-n@users.noreply.github.com> Date: Sun, 9 Jun 2024 20:47:16 +0200 Subject: [PATCH 22/22] Forgot to add Config alias --- lib/teiserver/battle/libs/match_lib.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/teiserver/battle/libs/match_lib.ex b/lib/teiserver/battle/libs/match_lib.ex index 7c53820bf..fb7734893 100644 --- a/lib/teiserver/battle/libs/match_lib.ex +++ b/lib/teiserver/battle/libs/match_lib.ex @@ -1,8 +1,7 @@ defmodule Teiserver.Battle.MatchLib do @moduledoc false use TeiserverWeb, :library - alias Teiserver.Config - alias Teiserver.{Battle, Account} + alias Teiserver.{Config, Battle, Account} alias Teiserver.Battle.{Match, MatchMembership} alias Teiserver.Data.Types, as: T require Logger