From a14d50ba2f4a5dfdaa167a63b55002812fef3c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 05:44:27 +0200 Subject: [PATCH 01/13] Show full email in smurf list --- .../templates/admin/user/smurf_list.html.heex | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/teiserver_web/templates/admin/user/smurf_list.html.heex b/lib/teiserver_web/templates/admin/user/smurf_list.html.heex index 709391758..65d380fba 100644 --- a/lib/teiserver_web/templates/admin/user/smurf_list.html.heex +++ b/lib/teiserver_web/templates/admin/user/smurf_list.html.heex @@ -132,17 +132,12 @@ is_moderator = allow?(@conn, "Moderator") %> - <% email_domain = - @user.email - |> String.split("@") - |> Enum.reverse() - |> hd %> <%= central_component("icon", icon: @user.icon) %> <%= @user.name %> - <%= email_domain %> + <%= @user.email %> <%= @user.data["lobby_client"] %> @@ -185,19 +180,15 @@ is_moderator = allow?(@conn, "Moderator") %> <%= for user <- @users do %> <% user_stats = @stats_map[user.id] - - email_domain = - user.email - |> String.split("@") - |> Enum.reverse() - |> hd %> + games_allied = @games_allied[user.id] + games_vs = @games_vs[user.id] %> <%= central_component("icon", icon: user.icon) %> <%= user.name %> - <%= email_domain %> + <%= user.email %> <%= user.data["lobby_client"] %> From 37fcdf86e126e541d2f9b0bb8dd53c2e189edac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 06:22:28 +0200 Subject: [PATCH 02/13] play time in smurf list --- .../templates/admin/user/smurf_list.html.heex | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/teiserver_web/templates/admin/user/smurf_list.html.heex b/lib/teiserver_web/templates/admin/user/smurf_list.html.heex index 65d380fba..a857f911b 100644 --- a/lib/teiserver_web/templates/admin/user/smurf_list.html.heex +++ b/lib/teiserver_web/templates/admin/user/smurf_list.html.heex @@ -115,6 +115,9 @@ is_moderator = allow?(@conn, "Moderator") %> Winrate Recents + Play time + games allied + games vs <%= for type <- @key_types do %> <%= short_name[type] || type %> @@ -132,7 +135,6 @@ is_moderator = allow?(@conn, "Moderator") %> - <%= central_component("icon", icon: @user.icon) %> @@ -146,6 +148,10 @@ is_moderator = allow?(@conn, "Moderator") %> <%= @stats["win_rate.team"] %> <%= @stats["recent_count.team"] %> + <% hours = ((@stats["player_minutes"] || 0) / 60) |> round %> + + <%= "#{hours}h" %> + <%= for _type <- @key_types do %> @@ -197,6 +203,10 @@ is_moderator = allow?(@conn, "Moderator") %> <%= user_stats["win_rate.team"] %> <%= user_stats["recent_count.team"] %> + <% hours = ((user_stats["player_minutes"] || 0) / 60) |> round %> + + <%= "#{hours}h" %> + <%= for type <- @key_types do %> @@ -259,9 +269,10 @@ is_moderator = allow?(@conn, "Moderator") %> class: "btn btn-sm btn-warning" ) %> - <% else %> + <% else # TODO if @user.smurf_of_id == nil, link to parent? %> <% end %> + <% end %> From 75ff7f74f6ff1cb9deb6796817df319d0cb67308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 07:12:51 +0200 Subject: [PATCH 03/13] Better report user page Added map, game duration info --- lib/teiserver_web/live/moderation/report_user/index.ex | 2 +- .../live/moderation/report_user/index.html.heex | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/teiserver_web/live/moderation/report_user/index.ex b/lib/teiserver_web/live/moderation/report_user/index.ex index 00db6e7b5..c82f15115 100644 --- a/lib/teiserver_web/live/moderation/report_user/index.ex +++ b/lib/teiserver_web/live/moderation/report_user/index.ex @@ -186,7 +186,7 @@ defmodule TeiserverWeb.Moderation.ReportUserLive.Index do user_id: user.id ], order_by: "Newest first", - select: [:id, :game_type, :team_size, :team_count, :finished, :map] + select: [:id, :game_type, :team_size, :team_count, :finished, :map, :game_duration] ) |> Enum.map(fn match -> label = diff --git a/lib/teiserver_web/live/moderation/report_user/index.html.heex b/lib/teiserver_web/live/moderation/report_user/index.html.heex index 7e6adcc1e..b6dc08f81 100644 --- a/lib/teiserver_web/live/moderation/report_user/index.html.heex +++ b/lib/teiserver_web/live/moderation/report_user/index.html.heex @@ -73,7 +73,11 @@ row_click={fn match -> "select-match-#{match.id}" end} > <:col :let={match} label="Match"><%= match.label %> - <:col :let={match} label=""><%= match.time_ago %> + <:col :let={match} label="Map"><%= match.map %> + <:col :let={match} label="When?"><%= match.time_ago %> + <:col :let={match} label="Match length"> + <%= duration_to_str_short(match.game_duration) %> + If you cannot find the match here then you can submit the report without a match selected but it may mean we cannot find evidence and are thus unable to handle the report.

From 440bc1a49e124dd1c92e23a1757259394da9f124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 07:15:29 +0200 Subject: [PATCH 04/13] Search reports by chat/actions/any --- .../controllers/moderation/report_controller.ex | 12 ++++++++++++ .../templates/moderation/report/search.html.heex | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/teiserver_web/controllers/moderation/report_controller.ex b/lib/teiserver_web/controllers/moderation/report_controller.ex index 2db956243..df03e052c 100644 --- a/lib/teiserver_web/controllers/moderation/report_controller.ex +++ b/lib/teiserver_web/controllers/moderation/report_controller.ex @@ -55,6 +55,18 @@ defmodule TeiserverWeb.Moderation.ReportController do order_by: params["order"] ) + reports = + case params["kind"] do + "Chat" -> + reports |> Enum.filter(fn report -> String.contains?(report.type, "chat") end) + + "Actions" -> + reports |> Enum.filter(fn report -> String.contains?(report.type, "actions") end) + + "Any" -> + reports + end + target = if params["target_id"] do Account.get_user(params["target_id"]) diff --git a/lib/teiserver_web/templates/moderation/report/search.html.heex b/lib/teiserver_web/templates/moderation/report/search.html.heex index 7cb163317..41a92067f 100644 --- a/lib/teiserver_web/templates/moderation/report/search.html.heex +++ b/lib/teiserver_web/templates/moderation/report/search.html.heex @@ -43,6 +43,20 @@ }) %> +
+ + <%= central_component("icon_dropdown", %{ + name: "search[kind]", + id: "search_kind", + selected: @params["kind"] || "Any", + enumerable: [ + %{id: "Any", icon: "fas fa-square", colour: fg}, + %{id: "Chat", icon: "fas fa-comment", colour: fg}, + %{id: "Actions", icon: "fas #{Teiserver.Moderation.ActionLib.icon()}", colour: fg} + ] + }) %> +
+
<%= central_component("icon_dropdown", %{ From 111333271103d73c98079cf5300ab4baace34e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 07:13:22 +0200 Subject: [PATCH 05/13] Disable dialyzer pre-commit for now --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11184e971..11e6a1a2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,10 +32,10 @@ repos: # language: system # pass_filenames: false # files: \.exs*$ - - id: mix-dialyzer - name: "elixir: mix dialyzer" - entry: mix dialyzer - language: system - pass_filenames: false - files: \.exs*$ + # - id: mix-dialyzer + # name: "elixir: mix dialyzer" + # entry: mix dialyzer + # language: system + # pass_filenames: false + # files: \.exs*$ From 0fd56cff38a2239442b00403baf4e186ffa9fce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 07:38:21 +0200 Subject: [PATCH 06/13] Replace moderation action icon with triangle-exclaimation --- lib/teiserver/moderation/libs/action_lib.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/teiserver/moderation/libs/action_lib.ex b/lib/teiserver/moderation/libs/action_lib.ex index 25c399808..e077c8a6f 100644 --- a/lib/teiserver/moderation/libs/action_lib.ex +++ b/lib/teiserver/moderation/libs/action_lib.ex @@ -7,7 +7,7 @@ defmodule Teiserver.Moderation.ActionLib do # Functions @spec icon :: String.t() - def icon, do: "fa-regular fa-exclamation" + def icon, do: "fa-regular fa-triangle-exclamation" @spec colour :: atom def colour, do: :primary From ba67110c33a8db923d4fb33f9b5f130c310ce056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 07:55:46 +0200 Subject: [PATCH 07/13] Fix battle/chat/:match_id/all links --- lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex | 5 +---- .../templates/moderation/report/tab_against.html.heex | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex b/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex index 4f2818a2c..0ea4cfe6c 100644 --- a/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex +++ b/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex @@ -60,10 +60,7 @@ <% end %> <%= if not @last_page or @page != 0 do %> - +   Full chat diff --git a/lib/teiserver_web/templates/moderation/report/tab_against.html.heex b/lib/teiserver_web/templates/moderation/report/tab_against.html.heex index 84578b89b..6b9f2cc66 100644 --- a/lib/teiserver_web/templates/moderation/report/tab_against.html.heex +++ b/lib/teiserver_web/templates/moderation/report/tab_against.html.heex @@ -30,7 +30,10 @@ - + Chat From 028daa82f1ba41ef5e99f5c7908891b678eb19ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 08:01:54 +0200 Subject: [PATCH 08/13] Allow filtering out Coordinator chat in chat logs --- lib/teiserver_web/live/battles/match/chat.ex | 12 +++++++++++- lib/teiserver_web/live/battles/match/chat.html.heex | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/teiserver_web/live/battles/match/chat.ex b/lib/teiserver_web/live/battles/match/chat.ex index 36216f19e..6177b548e 100644 --- a/lib/teiserver_web/live/battles/match/chat.ex +++ b/lib/teiserver_web/live/battles/match/chat.ex @@ -94,6 +94,14 @@ defmodule TeiserverWeb.Battle.MatchLive.Chat do end) |> Enum.reject(&(&1 == nil)) + user_exclude_list = + String.trim(filters["user-raw-exclude"] || "") + |> String.split(",") + |> Enum.map(fn username -> + Account.get_userid_from_name(username) + end) + |> Enum.reject(&(&1 == nil)) + contains_filter = filters["message-contains"] |> String.trim() @@ -102,7 +110,8 @@ defmodule TeiserverWeb.Battle.MatchLive.Chat do Chat.list_lobby_messages( search: [ match_id: match_id, - user_id_in: user_id_list + user_id_in: user_id_list, + user_id_not_in: user_exclude_list ], preload: [:user], limit: 1_000, @@ -183,6 +192,7 @@ defmodule TeiserverWeb.Battle.MatchLive.Chat do "bot-messages" => "Include bot messages", "message-format" => "Table", "user-raw-filter" => "", + "user-raw-exclude" => "Coordinator", "user-raw-highlight" => highlight_names, "message-contains" => "", "order_by" => "Oldest first" diff --git a/lib/teiserver_web/live/battles/match/chat.html.heex b/lib/teiserver_web/live/battles/match/chat.html.heex index 8052dc7e0..859f83ca8 100644 --- a/lib/teiserver_web/live/battles/match/chat.html.heex +++ b/lib/teiserver_web/live/battles/match/chat.html.heex @@ -108,6 +108,18 @@ />
+
+ <.input + type="text" + label="User exclude (split with commas)" + name="user-raw-exclude" + value={@filters["user-raw-exclude"]} + phx-change="filter-update" + phx-debounce="400" + /> +
+ +
<.input type="text" From bdbdea9b9237728c57bcb6d71f65361df7537c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 08:33:56 +0200 Subject: [PATCH 09/13] Migrate teiserver/admin/matches to battle/show --- .../live/battles/match/chat.html.heex | 1 - lib/teiserver_web/live/battles/match/show.ex | 122 +++++++++++++++++- .../live/battles/match/show.html.heex | 86 +++++++++++- lib/teiserver_web/router.ex | 1 + 4 files changed, 204 insertions(+), 6 deletions(-) diff --git a/lib/teiserver_web/live/battles/match/chat.html.heex b/lib/teiserver_web/live/battles/match/chat.html.heex index 859f83ca8..7ec685b10 100644 --- a/lib/teiserver_web/live/battles/match/chat.html.heex +++ b/lib/teiserver_web/live/battles/match/chat.html.heex @@ -119,7 +119,6 @@ />
-
<.input type="text" diff --git a/lib/teiserver_web/live/battles/match/show.ex b/lib/teiserver_web/live/battles/match/show.ex index a91d119a8..bd02fcf6b 100644 --- a/lib/teiserver_web/live/battles/match/show.ex +++ b/lib/teiserver_web/live/battles/match/show.ex @@ -1,8 +1,8 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do @moduledoc false use TeiserverWeb, :live_view - alias Teiserver.{Battle, Game} - alias Teiserver.Battle.MatchLib + alias Teiserver.{Battle, Game, Account, Telemetry} + alias Teiserver.Battle.{MatchLib, BalanceLib} @impl true def mount(_params, _session, socket) do @@ -38,10 +38,16 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do defp apply_action(%{assigns: %{match_name: match_name}} = socket, :ratings, _params) do socket - |> mount_require_any(["Reviewer"]) + |> mount_require_any(["Overwatch"]) |> assign(:page_title, "#{match_name} - Ratings") end + defp apply_action(%{assigns: %{match_name: match_name}} = socket, :events, _params) do + socket + |> mount_require_any(["Overwatch"]) + |> assign(:page_title, "#{match_name} - Events") + end + defp apply_action(%{assigns: %{match_name: match_name}} = socket, :balance, _params) do socket |> mount_require_any(["Reviewer"]) @@ -95,12 +101,88 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do end) |> Map.new() + # Now for balance related stuff + partied_players = + members + |> Enum.group_by(fn p -> p.party_id end, fn p -> p.user_id end) + + groups = + partied_players + |> Enum.map(fn + # The nil group is players without a party, they need to + # be broken out of the party + {nil, player_id_list} -> + player_id_list + |> Enum.filter(fn userid -> rating_logs[userid] != nil end) + |> Enum.map(fn userid -> + %{userid => rating_logs[userid].value["rating_value"]} + end) + + {_party_id, player_id_list} -> + player_id_list + |> Enum.filter(fn userid -> rating_logs[userid] != nil end) + |> Map.new(fn userid -> + {userid, rating_logs[userid].value["rating_value"]} + end) + end) + |> List.flatten() + + past_balance = + BalanceLib.create_balance(groups, match.team_count, mode: :loser_picks) + |> Map.put(:balance_mode, :grouped) + + # What about new balance? + new_balance = generate_new_balance_data(match) + + raw_events = + Telemetry.list_simple_match_events(where: [match_id: match.id], preload: [:event_types]) + + events_by_type = + raw_events + |> Enum.group_by( + fn e -> + e.event_type.name + end, + fn _ -> + 1 + end + ) + |> Enum.map(fn {name, vs} -> + {name, Enum.count(vs)} + end) + |> Enum.sort_by(fn v -> v end, &<=/2) + + team_lookup = + members + |> Map.new(fn m -> + {m.user_id, m.team_id} + end) + + events_by_team_and_type = + raw_events + |> Enum.group_by( + fn e -> + {team_lookup[e.user_id] || -1, e.event_type.name} + end, + fn _ -> + 1 + end + ) + |> Enum.map(fn {key, vs} -> + {key, Enum.count(vs)} + end) + |> Enum.sort_by(fn v -> v end, &<=/2) + socket |> assign(:match, match) |> assign(:match_name, match_name) |> assign(:members, members) |> assign(:rating_logs, rating_logs) |> assign(:parties, parties) + |> assign(:past_balance, past_balance) + |> assign(:new_balance, new_balance) + |> assign(:events_by_type, events_by_type) + |> assign(:events_by_team_and_type, events_by_team_and_type) else socket |> assign(:match, nil) @@ -108,6 +190,40 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do |> assign(:members, []) |> assign(:rating_logs, []) |> assign(:parties, %{}) + |> assign(:past_balance, %{}) + |> assign(:new_balance, %{}) + |> assign(:events_by_type, %{}) + |> assign(:events_by_team_and_type, %{}) end end + + defp generate_new_balance_data(match) do + rating_type = MatchLib.game_type(match.team_size, match.team_count) + + partied_players = + match.members + |> Enum.group_by(fn p -> p.party_id end, fn p -> p.user_id end) + + groups = + partied_players + |> Enum.map(fn + # The nil group is players without a party, they need to + # be broken out of the party + {nil, player_id_list} -> + player_id_list + |> Enum.map(fn userid -> + %{userid => BalanceLib.get_user_rating_rank(userid, rating_type)} + end) + + {_party_id, player_id_list} -> + player_id_list + |> Map.new(fn userid -> + {userid, BalanceLib.get_user_rating_rank(userid, rating_type)} + end) + end) + |> List.flatten() + + BalanceLib.create_balance(groups, match.team_count, mode: :loser_picks) + |> Map.put(:balance_mode, :grouped) + end end diff --git a/lib/teiserver_web/live/battles/match/show.html.heex b/lib/teiserver_web/live/battles/match/show.html.heex index eea6a6bc7..d96ecad00 100644 --- a/lib/teiserver_web/live/battles/match/show.html.heex +++ b/lib/teiserver_web/live/battles/match/show.html.heex @@ -35,11 +35,24 @@ Players - <%= if @rating_logs != %{} and allow?(@current_user, "Reviewer") do %> + <%= if @rating_logs != %{} and allow?(@current_user, "Overwatch") do %> <.tab_nav url={~p"/battle/#{@match.id}/ratings"} selected={@tab == :ratings}> Ratings <% end %> + + <%= if @new_balance != %{} and allow?(@current_user, "Overwatch") do %> + <.tab_nav url={~p"/battle/#{@match.id}/balance"} selected={@tab == :balance}> + Balance + + <% end %> + + <%= if @events_by_type != %{} and allow?(@current_user, "Overwatch") do %> + <.tab_nav url={~p"/battle/#{@match.id}/events"} selected={@tab == :events}> + + Events + + <% end %>
@@ -204,7 +217,7 @@
- <%= if allow?(@current_user, "Reviewer") do %> + <%= if allow?(@current_user, "Overwatch") do %>
@@ -268,5 +281,74 @@
<% end %> + + <%= if allow?(@current_user, "Overwatch") do %> +
+

Based on data at the time

+ + + + + + + + + + + + + + + +
Team 1<%= @past_balance.ratings[1] |> round(2) %>
Team 2<%= @past_balance.ratings[2] |> round(2) %>
Deviation<%= @past_balance.deviation %>
+ + + +
+ +

If balance we made using current ratings

+ + + + + + + + + + + + + + + +
Team 1<%= @new_balance.ratings[1] |> round(2) %>
Team 2<%= @new_balance.ratings[2] |> round(2) %>
Deviation<%= @new_balance.deviation %>
+ + +
+ <% end %> + + <%= if allow?(@current_user, "Overwatch") do %> +
+
+
+

By type

+ <.table id="by_type" rows={@events_by_type} table_class="table-sm"> + <:col :let={{name, _}} label="Event"><%= name %> + <:col :let={{_, count}} label="Count"><%= count %> + +
+ +
+

By team and type

+ <.table id="by_type" rows={@events_by_team_and_type} table_class="table-sm"> + <:col :let={{{team, _}, _}} label="Team"><%= team + 1 %> + <:col :let={{{_, name}, _}} label="Event"><%= name %> + <:col :let={{_, count}} label="Count"><%= count %> + +
+
+
+ <% end %>
diff --git a/lib/teiserver_web/router.ex b/lib/teiserver_web/router.ex index 7ff524307..7851b490a 100644 --- a/lib/teiserver_web/router.ex +++ b/lib/teiserver_web/router.ex @@ -304,6 +304,7 @@ defmodule TeiserverWeb.Router do live "/:id/players", MatchLive.Show, :players live "/:id/ratings", MatchLive.Show, :ratings live "/:id/balance", MatchLive.Show, :balance + live "/:id/events", MatchLive.Show, :events end end From 06e8db3831cce4eef9f8c6612ee0b848918b316a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 08:58:38 +0200 Subject: [PATCH 10/13] Deprecate admin/matches/:match_id in favor of battle/:match_id --- .../controllers/admin/match_controller.ex | 154 +----------------- .../live/battles/match/match_components.ex | 2 +- .../live/battles/match/show.html.heex | 2 +- .../live/moderation/overwatch/index.html.heex | 2 +- .../overwatch/report_group_detail.html.heex | 2 +- .../live/moderation/overwatch/user.html.heex | 2 +- .../admin/lobby/lobby_chat.html.heex | 2 +- .../templates/admin/match/index.html.heex | 5 +- .../admin/match/server_index.html.heex | 5 +- .../templates/admin/match/show.html.heex | 112 ------------- .../admin/match/tab_balance.html.heex | 41 ----- .../admin/match/tab_details.html.heex | 37 ----- .../admin/match/tab_events.html.heex | 18 -- .../admin/match/tab_players.html.heex | 109 ------------- .../admin/match/tab_ratings.html.heex | 81 --------- .../admin/match/user_index.html.heex | 5 +- .../templates/admin/user/ratings.html.heex | 5 +- .../battle/match/section_menu.html.heex | 2 +- .../moderation/action/tab_reports.html.heex | 5 +- .../moderation/proposal/tab_reports.html.heex | 5 +- .../moderation/report/index.html.heex | 5 +- .../moderation/report/tab_from.html.heex | 5 +- .../simple_match_event/detail.html.heex | 5 +- 23 files changed, 21 insertions(+), 590 deletions(-) delete mode 100644 lib/teiserver_web/templates/admin/match/show.html.heex delete mode 100644 lib/teiserver_web/templates/admin/match/tab_balance.html.heex delete mode 100644 lib/teiserver_web/templates/admin/match/tab_details.html.heex delete mode 100644 lib/teiserver_web/templates/admin/match/tab_events.html.heex delete mode 100644 lib/teiserver_web/templates/admin/match/tab_players.html.heex delete mode 100644 lib/teiserver_web/templates/admin/match/tab_ratings.html.heex diff --git a/lib/teiserver_web/controllers/admin/match_controller.ex b/lib/teiserver_web/controllers/admin/match_controller.ex index 7da660709..0261e32ea 100644 --- a/lib/teiserver_web/controllers/admin/match_controller.ex +++ b/lib/teiserver_web/controllers/admin/match_controller.ex @@ -68,126 +68,12 @@ defmodule TeiserverWeb.Admin.MatchController do @spec show(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def show(conn, %{"id" => id}) do - match = - Battle.get_match!(id, - joins: [], - preload: [:members_and_users] - ) - - members = - match.members - |> Enum.sort_by(fn m -> m.user.name end, &<=/2) - |> Enum.sort_by(fn m -> m.team_id end, &<=/2) - - match - |> MatchLib.make_favourite() - |> insert_recently(conn) - - match_name = MatchLib.make_match_name(match) - - rating_logs = - Game.list_rating_logs( - search: [ - match_id: match.id - ] - ) - |> Map.new(fn log -> {log.user_id, log} end) - - # Creates a map where the party_id refers to an integer - # but only includes parties with 2 or more members - parties = - members - |> Enum.group_by(fn m -> m.party_id end) - |> Map.drop([nil]) - |> Map.filter(fn {_id, members} -> Enum.count(members) > 1 end) - |> Map.keys() - |> Enum.zip(Teiserver.Helper.StylingHelper.bright_hex_colour_list()) - |> Map.new() - - # Now for balance related stuff - partied_players = - members - |> Enum.group_by(fn p -> p.party_id end, fn p -> p.user_id end) - - groups = - partied_players - |> Enum.map(fn - # The nil group is players without a party, they need to - # be broken out of the party - {nil, player_id_list} -> - player_id_list - |> Enum.filter(fn userid -> rating_logs[userid] != nil end) - |> Enum.map(fn userid -> - %{userid => rating_logs[userid].value["rating_value"]} - end) - - {_party_id, player_id_list} -> - player_id_list - |> Enum.filter(fn userid -> rating_logs[userid] != nil end) - |> Map.new(fn userid -> - {userid, rating_logs[userid].value["rating_value"]} - end) - end) - |> List.flatten() - - past_balance = - BalanceLib.create_balance(groups, match.team_count, mode: :loser_picks) - |> Map.put(:balance_mode, :grouped) - - # What about new balance? - new_balance = generate_new_balance_data(match) - - raw_events = - Telemetry.list_simple_match_events(where: [match_id: match.id], preload: [:event_types]) - - events_by_type = - raw_events - |> Enum.group_by( - fn e -> - e.event_type.name - end, - fn _ -> - 1 - end - ) - |> Enum.map(fn {name, vs} -> - {name, Enum.count(vs)} - end) - |> Enum.sort_by(fn v -> v end, &<=/2) - - team_lookup = - members - |> Map.new(fn m -> - {m.user_id, m.team_id} - end) - - events_by_team_and_type = - raw_events - |> Enum.group_by( - fn e -> - {team_lookup[e.user_id] || -1, e.event_type.name} - end, - fn _ -> - 1 - end - ) - |> Enum.map(fn {key, vs} -> - {key, Enum.count(vs)} - end) - |> Enum.sort_by(fn v -> v end, &<=/2) - conn - |> assign(:match, match) - |> assign(:match_name, match_name) - |> assign(:members, members) - |> assign(:rating_logs, rating_logs) - |> assign(:parties, parties) - |> assign(:past_balance, past_balance) - |> assign(:new_balance, new_balance) - |> assign(:events_by_type, events_by_type) - |> assign(:events_by_team_and_type, events_by_team_and_type) - |> add_breadcrumb(name: "Show: #{match_name}", url: conn.request_path) - |> render("show.html") + |> put_flash( + :info, + "/teiserver/admin/matches/:match_id is deprecated in favor of /battle/:id" + ) + |> redirect(to: ~p"/battle/#{id}") end @spec user_show(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() @@ -229,34 +115,4 @@ defmodule TeiserverWeb.Admin.MatchController do |> assign(:matches, matches) |> render("server_index.html") end - - defp generate_new_balance_data(match) do - rating_type = MatchLib.game_type(match.team_size, match.team_count) - - partied_players = - match.members - |> Enum.group_by(fn p -> p.party_id end, fn p -> p.user_id end) - - groups = - partied_players - |> Enum.map(fn - # The nil group is players without a party, they need to - # be broken out of the party - {nil, player_id_list} -> - player_id_list - |> Enum.map(fn userid -> - %{userid => BalanceLib.get_user_rating_rank(userid, rating_type)} - end) - - {_party_id, player_id_list} -> - player_id_list - |> Map.new(fn userid -> - {userid, BalanceLib.get_user_rating_rank(userid, rating_type)} - end) - end) - |> List.flatten() - - BalanceLib.create_balance(groups, match.team_count, mode: :loser_picks) - |> Map.put(:balance_mode, :grouped) - end end diff --git a/lib/teiserver_web/live/battles/match/match_components.ex b/lib/teiserver_web/live/battles/match/match_components.ex index b6a92efcb..45910b47e 100644 --- a/lib/teiserver_web/live/battles/match/match_components.ex +++ b/lib/teiserver_web/live/battles/match/match_components.ex @@ -67,7 +67,7 @@ defmodule TeiserverWeb.Battle.MatchComponents do bsname={@view_colour} icon={StylingHelper.icon(:admin)} active={false} - url={~p"/teiserver/admin/matches/#{@match_id}"} + url={~p"/battle/#{@match_id}"} > Admin view diff --git a/lib/teiserver_web/live/battles/match/show.html.heex b/lib/teiserver_web/live/battles/match/show.html.heex index d96ecad00..a38abbee4 100644 --- a/lib/teiserver_web/live/battles/match/show.html.heex +++ b/lib/teiserver_web/live/battles/match/show.html.heex @@ -41,7 +41,7 @@ <% end %> - <%= if @new_balance != %{} and allow?(@current_user, "Overwatch") do %> + <%= if @rating_logs != %{} and allow?(@current_user, "Overwatch") do %> <.tab_nav url={~p"/battle/#{@match.id}/balance"} selected={@tab == :balance}> Balance diff --git a/lib/teiserver_web/live/moderation/overwatch/index.html.heex b/lib/teiserver_web/live/moderation/overwatch/index.html.heex index 2b2d3afb2..47aa5e371 100644 --- a/lib/teiserver_web/live/moderation/overwatch/index.html.heex +++ b/lib/teiserver_web/live/moderation/overwatch/index.html.heex @@ -132,7 +132,7 @@ <.link :if={report_group.match_id} class="btn btn-secondary btn-sm" - navigate={~p"/teiserver/admin/matches/#{report_group.match_id}"} + navigate={~p"/battle/#{report_group.match_id}"} > Match diff --git a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex index c889cc848..1c2bfc042 100644 --- a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex +++ b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex @@ -21,7 +21,7 @@ <%= if @report_group.match_id do %> Match Details diff --git a/lib/teiserver_web/live/moderation/overwatch/user.html.heex b/lib/teiserver_web/live/moderation/overwatch/user.html.heex index e6d455341..b8d5a8040 100644 --- a/lib/teiserver_web/live/moderation/overwatch/user.html.heex +++ b/lib/teiserver_web/live/moderation/overwatch/user.html.heex @@ -131,7 +131,7 @@ <.link :if={report_group.match_id} class="btn btn-secondary btn-sm" - navigate={~p"/teiserver/admin/matches/#{report_group.match_id}"} + navigate={~p"/battle/#{report_group.match_id}"} > Match diff --git a/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex b/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex index 0ea4cfe6c..96d9eea60 100644 --- a/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex +++ b/lib/teiserver_web/templates/admin/lobby/lobby_chat.html.heex @@ -52,7 +52,7 @@ <% end %>     <%= central_component("icon", icon: Teiserver.Battle.MatchLib.icon()) %> Match details diff --git a/lib/teiserver_web/templates/admin/match/index.html.heex b/lib/teiserver_web/templates/admin/match/index.html.heex index 2665b9bc4..b490f9f17 100644 --- a/lib/teiserver_web/templates/admin/match/index.html.heex +++ b/lib/teiserver_web/templates/admin/match/index.html.heex @@ -74,10 +74,7 @@ <%= date_to_str(match.finished, format: :ymd_hms) %> - + Show diff --git a/lib/teiserver_web/templates/admin/match/server_index.html.heex b/lib/teiserver_web/templates/admin/match/server_index.html.heex index f02a4b7b1..70b7bb807 100644 --- a/lib/teiserver_web/templates/admin/match/server_index.html.heex +++ b/lib/teiserver_web/templates/admin/match/server_index.html.heex @@ -87,10 +87,7 @@ <%= date_to_str(match.finished, format: :ymd_hms) %> - + Show diff --git a/lib/teiserver_web/templates/admin/match/show.html.heex b/lib/teiserver_web/templates/admin/match/show.html.heex deleted file mode 100644 index a0912581e..000000000 --- a/lib/teiserver_web/templates/admin/match/show.html.heex +++ /dev/null @@ -1,112 +0,0 @@ -<% bsname = view_colour() %> - - - -<%= render( - TeiserverWeb.Admin.GeneralView, - "sub_menu.html", - Map.merge(assigns, %{active: "matches"}) -) %> - -
-
-
-
- <%= render( - TeiserverWeb.Admin.MatchView, - "section_menu.html", - Map.merge(assigns, %{ - show_search: false, - active: "" - }) - ) %> -
- -
-   -
- -

- <%= @match_name %>      - <%= if @match.winning_team != nil do %> - Team <%= @match.winning_team + 1 %> won -      - <% end %> - Duration: <%= duration_to_str_short(@match.game_duration) %> -

-
- - -
-
- <%= render("tab_details.html", assigns) %> -
- -
- <%= render("tab_players.html", assigns) %> -
- - <%= if @rating_logs != %{} and allow?(@conn, "Reviewer") do %> -
- <%= render("tab_ratings.html", assigns) %> -
- -
- <%= render("tab_balance.html", assigns) %> -
- <% end %> - - <%= if @rating_logs != %{} and allow?(@conn, "Reviewer") do %> -
- <%= render("tab_events.html", assigns) %> -
- <% end %> -
-
-
-
-
diff --git a/lib/teiserver_web/templates/admin/match/tab_balance.html.heex b/lib/teiserver_web/templates/admin/match/tab_balance.html.heex deleted file mode 100644 index e5a47bf31..000000000 --- a/lib/teiserver_web/templates/admin/match/tab_balance.html.heex +++ /dev/null @@ -1,41 +0,0 @@ -

Based on data at the time

- - - - - - - - - - - - - - - -
Team 1<%= @past_balance.ratings[1] |> round(2) %>
Team 2<%= @past_balance.ratings[2] |> round(2) %>
Deviation<%= @past_balance.deviation %>
- - - -
- -

If balance we made using current ratings

- - - - - - - - - - - - - - - -
Team 1<%= @new_balance.ratings[1] |> round(2) %>
Team 2<%= @new_balance.ratings[2] |> round(2) %>
Deviation<%= @new_balance.deviation %>
- - diff --git a/lib/teiserver_web/templates/admin/match/tab_details.html.heex b/lib/teiserver_web/templates/admin/match/tab_details.html.heex deleted file mode 100644 index f583f4e68..000000000 --- a/lib/teiserver_web/templates/admin/match/tab_details.html.heex +++ /dev/null @@ -1,37 +0,0 @@ -<%= central_component("detail_line", - label: "Team count", - value: @match.team_count -) %> - -<%= central_component("detail_line", - label: "Team size", - value: @match.team_size -) %> - -
- -<%= central_component("detail_line", - label: "Started", - value: date_to_str(@match.started, format: :ymd_hms, tz: @tz) -) %> - -<%= central_component("detail_line", - label: "Finished", - value: date_to_str(@match.finished, format: :ymd_hms, tz: @tz) -) %> - -<%= if allow?(@conn, "admin.dev") do %> - <%= central_component("detail_line", - label: "Tag key count", - value: Map.keys(@match.tags) |> Enum.count() - ) %> -<% end %> - -<%= if allow?(@conn, "Moderator") do %> -
- Match data Match bots -<% end %> diff --git a/lib/teiserver_web/templates/admin/match/tab_events.html.heex b/lib/teiserver_web/templates/admin/match/tab_events.html.heex deleted file mode 100644 index ed4b8595e..000000000 --- a/lib/teiserver_web/templates/admin/match/tab_events.html.heex +++ /dev/null @@ -1,18 +0,0 @@ -
-
-

By type

- <.table id="by_type" rows={@events_by_type} table_class="table-sm"> - <:col :let={{name, _}} label="Event"><%= name %> - <:col :let={{_, count}} label="Count"><%= count %> - -
- -
-

By team and type

- <.table id="by_type" rows={@events_by_team_and_type} table_class="table-sm"> - <:col :let={{{team, _}, _}} label="Team"><%= team + 1 %> - <:col :let={{{_, name}, _}} label="Event"><%= name %> - <:col :let={{_, count}} label="Count"><%= count %> - -
-
diff --git a/lib/teiserver_web/templates/admin/match/tab_players.html.heex b/lib/teiserver_web/templates/admin/match/tab_players.html.heex deleted file mode 100644 index 8652d84ec..000000000 --- a/lib/teiserver_web/templates/admin/match/tab_players.html.heex +++ /dev/null @@ -1,109 +0,0 @@ -<% bsname = view_colour() %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%= for m <- @members do %> - <% rating = @rating_logs[m.user_id] - party_colour = @parties[m.party_id] - - exit_status = calculate_exit_status(m.left_after, @match.game_duration) - - play_percentage = - if exit_status != :stayed do - (m.left_after / @match.game_duration * 100) |> round - end %> - - - - - - <%= if party_colour do %> - - <% else %> - - <% end %> - - - - - - - - - - - - - - - - - - - - - <% end %> - -
 DamageUnitsMetalEnergy 
Name & PartyTeamPlayDoneTakenKilledProdProdUsedProdUsedRating 
- <%= if m.team_id == @match.winning_team do %> - - <% end %> - - <%= central_component("icon", icon: m.user.icon) %> - - <%= m.user.name %> -   <%= m.team_id + 1 %> - <%= case exit_status do %> - <% :stayed -> %> - <% :early -> %> -   <%= play_percentage %>% - <% :abandoned -> %> - -   <%= play_percentage %>% - <% :noshow -> %> - - <% end %> - <%= normalize(m.stats["damageDealt"]) %><%= normalize(m.stats["damageReceived"]) %><%= normalize(m.stats["unitsKilled"]) %><%= normalize(m.stats["unitsProduced"]) %><%= normalize(m.stats["metalProduced"]) %><%= normalize(m.stats["metalUsed"]) %><%= normalize(m.stats["energyProduced"]) %><%= normalize(m.stats["energyUsed"]) %> - <%= if rating != nil do %> - <%= rating.value["rating_value"] |> round(2) %> - <% end %> - - - Matches - -
diff --git a/lib/teiserver_web/templates/admin/match/tab_ratings.html.heex b/lib/teiserver_web/templates/admin/match/tab_ratings.html.heex deleted file mode 100644 index a4d15fa84..000000000 --- a/lib/teiserver_web/templates/admin/match/tab_ratings.html.heex +++ /dev/null @@ -1,81 +0,0 @@ -<%= if @rating_logs != %{} do %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <%= for m <- @members do %> - <% rating = @rating_logs[m.user_id] %> - - - - - - - - - - - - - - - - - - - - - - <% end %> - -
 Rating Change 
NameTeamRatingSkillUncertainty RatingSkillUncertainty 
- <%= if m.team_id == @match.winning_team do %> - - <% end %> - - <%= central_component("icon", icon: m.user.icon) %> - <%= m.user.name %><%= m.team_id + 1 %><%= rating.value["rating_value"] |> round(2) %><%= rating.value["skill"] |> round(2) %><%= rating.value["uncertainty"] |> round(2) %> <%= rating.value["rating_value_change"] |> round(2) %><%= rating.value["skill_change"] |> round(2) %><%= rating.value["uncertainty_change"] |> round(2) %> - - Show/Hide raw - -
- -
-<% end %> diff --git a/lib/teiserver_web/templates/admin/match/user_index.html.heex b/lib/teiserver_web/templates/admin/match/user_index.html.heex index 4ce294b0c..f924d6a8a 100644 --- a/lib/teiserver_web/templates/admin/match/user_index.html.heex +++ b/lib/teiserver_web/templates/admin/match/user_index.html.heex @@ -96,10 +96,7 @@ <%= date_to_str(match.finished, format: :ymd_hms) %> - + Show diff --git a/lib/teiserver_web/templates/admin/user/ratings.html.heex b/lib/teiserver_web/templates/admin/user/ratings.html.heex index 73d00b92a..aa0cbdbf6 100644 --- a/lib/teiserver_web/templates/admin/user/ratings.html.heex +++ b/lib/teiserver_web/templates/admin/user/ratings.html.heex @@ -184,10 +184,7 @@ <%= date_to_str(log.inserted_at, format: :hms_or_dmy) %> <%= if log.match do %> - + Show diff --git a/lib/teiserver_web/templates/battle/match/section_menu.html.heex b/lib/teiserver_web/templates/battle/match/section_menu.html.heex index 96912e1b0..7578d689d 100644 --- a/lib/teiserver_web/templates/battle/match/section_menu.html.heex +++ b/lib/teiserver_web/templates/battle/match/section_menu.html.heex @@ -37,7 +37,7 @@ active: @active, icon: Teiserver.Admin.AdminLib.icon(), bsname: bsname, - url: ~p"/teiserver/admin/matches/#{@match.id}" + url: ~p"/battle/#{@match.id}" ) %> <% end %> diff --git a/lib/teiserver_web/templates/moderation/action/tab_reports.html.heex b/lib/teiserver_web/templates/moderation/action/tab_reports.html.heex index f332b4f40..cd3e7d0a6 100644 --- a/lib/teiserver_web/templates/moderation/action/tab_reports.html.heex +++ b/lib/teiserver_web/templates/moderation/action/tab_reports.html.heex @@ -29,10 +29,7 @@ <%= if report.match_id do %> - + Match <% end %> diff --git a/lib/teiserver_web/templates/moderation/proposal/tab_reports.html.heex b/lib/teiserver_web/templates/moderation/proposal/tab_reports.html.heex index 0c19aeba5..2f5111735 100644 --- a/lib/teiserver_web/templates/moderation/proposal/tab_reports.html.heex +++ b/lib/teiserver_web/templates/moderation/proposal/tab_reports.html.heex @@ -20,10 +20,7 @@ <%= if report.match_id do %> <%= report.relationship %> - + Match diff --git a/lib/teiserver_web/templates/moderation/report/index.html.heex b/lib/teiserver_web/templates/moderation/report/index.html.heex index bdbd3275e..dba93fecb 100644 --- a/lib/teiserver_web/templates/moderation/report/index.html.heex +++ b/lib/teiserver_web/templates/moderation/report/index.html.heex @@ -112,10 +112,7 @@ <%= if report.match_id do %> - + Match diff --git a/lib/teiserver_web/templates/moderation/report/tab_from.html.heex b/lib/teiserver_web/templates/moderation/report/tab_from.html.heex index 438685a4e..e1e74312b 100644 --- a/lib/teiserver_web/templates/moderation/report/tab_from.html.heex +++ b/lib/teiserver_web/templates/moderation/report/tab_from.html.heex @@ -22,10 +22,7 @@ <%= if report.match_id do %> <%= report.relationship %> - + Match diff --git a/lib/teiserver_web/templates/telemetry/simple_match_event/detail.html.heex b/lib/teiserver_web/templates/telemetry/simple_match_event/detail.html.heex index cec50cae1..c2bc205fe 100644 --- a/lib/teiserver_web/templates/telemetry/simple_match_event/detail.html.heex +++ b/lib/teiserver_web/templates/telemetry/simple_match_event/detail.html.heex @@ -78,10 +78,7 @@ <%= match_id %> <%= format_number(count) %> - <.link - navigate={~p"/teiserver/admin/matches/#{match_id}"} - class="btn btn-sm btn-secondary" - > + <.link navigate={~p"/battle/#{match_id}"} class="btn btn-sm btn-secondary"> Show From f45c83d7d14a742a082e388ef967f712a02f1afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 11:05:20 +0200 Subject: [PATCH 11/13] Allow filtering on kind of reports in Overwatch page --- .../moderation/queries/report_group_queries.ex | 8 ++++++++ lib/teiserver_web/live/moderation/overwatch/index.ex | 9 +++++++++ .../live/moderation/overwatch/index.html.heex | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/lib/teiserver/moderation/queries/report_group_queries.ex b/lib/teiserver/moderation/queries/report_group_queries.ex index 115a1e56c..3ebb53e56 100644 --- a/lib/teiserver/moderation/queries/report_group_queries.ex +++ b/lib/teiserver/moderation/queries/report_group_queries.ex @@ -78,6 +78,14 @@ defmodule Teiserver.Moderation.ReportGroupQueries do where: report_groups.inserted_at >= ^datetime end + defp _where(query, :has_reports_of_kind, kind) do + from report_groups in query, + join: reports in assoc(report_groups, :reports), + where: fragment("? ~* ?", reports.type, ^kind) + end + + defp _where(query, :has_reports_of_kind, nil), do: query + @spec do_order_by(Ecto.Query.t(), list | nil) :: Ecto.Query.t() defp do_order_by(query, nil), do: query diff --git a/lib/teiserver_web/live/moderation/overwatch/index.ex b/lib/teiserver_web/live/moderation/overwatch/index.ex index cd86c0c26..aae0923a0 100644 --- a/lib/teiserver_web/live/moderation/overwatch/index.ex +++ b/lib/teiserver_web/live/moderation/overwatch/index.ex @@ -56,6 +56,7 @@ defmodule TeiserverWeb.Moderation.OverwatchLive.Index do %{ "actioned-filter" => "All", "closed-filter" => "Open", + "kind-filter" => "Any", "timeframe-filter" => "standard", "target_id" => Map.get(params, "target_id") }, @@ -90,12 +91,20 @@ defmodule TeiserverWeb.Moderation.OverwatchLive.Index do _ -> nil end + kind = + case filters["kind-filter"] do + "Any" -> nil + "Actions" -> "actions" + "Chat" -> "chat" + end + report_groups = Moderation.list_report_groups( where: [ closed: closed_filter, actioned: actioned_filter, inserted_after: timeframe, + has_reports_of_kind: kind, target_id: filters["target_id"] ], order_by: ["Newest first"], diff --git a/lib/teiserver_web/live/moderation/overwatch/index.html.heex b/lib/teiserver_web/live/moderation/overwatch/index.html.heex index 47aa5e371..0bc995109 100644 --- a/lib/teiserver_web/live/moderation/overwatch/index.html.heex +++ b/lib/teiserver_web/live/moderation/overwatch/index.html.heex @@ -57,6 +57,17 @@ /> +
+ <.input + type="select" + label="Kind" + options={["Any", "Actions", "Chat"]} + name="kind-filter" + value={@filters["kind-filter"]} + phx-change="filter-update" + /> +
+
<.input type="select" From 1d7e3561d0cb42f04b8a4ed1c2b57dc12739bc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 12:41:00 +0200 Subject: [PATCH 12/13] Todo notes for overwatch page --- lib/teiserver/moderation/queries/report_group_queries.ex | 2 ++ .../live/moderation/overwatch/report_group_detail.ex | 2 ++ .../live/moderation/overwatch/report_group_detail.html.heex | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/teiserver/moderation/queries/report_group_queries.ex b/lib/teiserver/moderation/queries/report_group_queries.ex index 3ebb53e56..f1c594c4e 100644 --- a/lib/teiserver/moderation/queries/report_group_queries.ex +++ b/lib/teiserver/moderation/queries/report_group_queries.ex @@ -136,6 +136,8 @@ defmodule Teiserver.Moderation.ReportGroupQueries do from report_groups in query, left_join: reports in assoc(report_groups, :reports), preload: [reports: reports] + + # TODO add reporters here end # defp _preload(query, :users) do diff --git a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.ex b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.ex index b6a47f19b..0b6840948 100644 --- a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.ex +++ b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.ex @@ -14,6 +14,8 @@ defmodule TeiserverWeb.Moderation.OverwatchLive.ReportGroupDetail do |> ReportGroupLib.make_favourite() |> insert_recently(socket) + # TODO also assign reporter info here, it's needed for report authors and chat link + socket = socket |> assign(:report_group, report_group) diff --git a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex index 1c2bfc042..4760e2db7 100644 --- a/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex +++ b/lib/teiserver_web/live/moderation/overwatch/report_group_detail.html.heex @@ -118,7 +118,7 @@ row_click={fn report -> JS.navigate(~p"/moderation/report/#{report.id}") end} > <:col :let={report} label="Type"><%= report.type %>/<%= report.sub_type %> - <:col :let={report} label="Type"><%= report.extra_text %> + <:col :let={report} label="Description"><%= report.extra_text %> <:col :let={report} label="Type"> <%= date_to_str(report.inserted_at, format: :hms_or_ymd) %> From 9b00564f88bb22300a2d3b36385b67e208ccf0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Wed, 12 Jun 2024 12:41:29 +0200 Subject: [PATCH 13/13] Fix close buttons on /moderation/report/user/:user_id --- .../templates/moderation/report/tab_against.html.heex | 6 ++++++ .../templates/moderation/report/tab_from.html.heex | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/teiserver_web/templates/moderation/report/tab_against.html.heex b/lib/teiserver_web/templates/moderation/report/tab_against.html.heex index 6b9f2cc66..65a9bcdc2 100644 --- a/lib/teiserver_web/templates/moderation/report/tab_against.html.heex +++ b/lib/teiserver_web/templates/moderation/report/tab_against.html.heex @@ -55,6 +55,12 @@ ) %> <% end %> + + <%= if report.closed do %> + + + + <% end %> diff --git a/lib/teiserver_web/templates/moderation/report/tab_from.html.heex b/lib/teiserver_web/templates/moderation/report/tab_from.html.heex index e1e74312b..7f3b72334 100644 --- a/lib/teiserver_web/templates/moderation/report/tab_from.html.heex +++ b/lib/teiserver_web/templates/moderation/report/tab_from.html.heex @@ -49,6 +49,12 @@ ) %> <% end %> + + <%= if report.closed do %> + + + + <% end %>