Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge queue attempt 1 #351

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff5a179
Concache supervisor in cache helpers
geekingfrog May 20, 2024
09dbd6b
Better restrictions titles
jauggy Jun 13, 2024
a8aa85a
Fix some more icons
geekingfrog Jun 14, 2024
174f657
Improve whoami and whois
jauggy Jun 15, 2024
8e50c1f
Reserve Host[.* when renaming accounts
Beherith Jun 19, 2024
c8fc827
Update based on Lexon feedback
jauggy Jun 28, 2024
03d6239
Tag all failing tests
geekingfrog Jun 5, 2024
925c2b8
Don't run tagged tests in CI
geekingfrog Jun 5, 2024
56b5ac8
Fix timezone when testing time related stuff
geekingfrog Jun 27, 2024
6622368
Don't rely on fixed username
geekingfrog Jun 27, 2024
5764549
Ignore tachyon related flaky tests
geekingfrog Jun 27, 2024
984596b
Move test lib under test
geekingfrog Jul 4, 2024
6da86e2
Add the last dialyzer ignore
geekingfrog Jul 4, 2024
4c8239a
Add and fix some missing types
geekingfrog Jul 4, 2024
44b7ce7
Permissions cache
geekingfrog May 20, 2024
867916e
Logging permission
geekingfrog May 20, 2024
5dc42fb
Profile config
geekingfrog May 20, 2024
0c19128
Site config
geekingfrog May 20, 2024
3b887cb
Metadata cache
geekingfrog May 20, 2024
11b1d9e
Text callbacks
geekingfrog May 20, 2024
b1497b8
Move teiserver site config to supervisors
geekingfrog May 20, 2024
bb90256
Warm up metadata cache with audit type
geekingfrog May 20, 2024
8cd5da2
Tachyon caches to supervisors
geekingfrog May 20, 2024
b4958b6
Lobby command cache
geekingfrog May 20, 2024
c8720d7
Matchmaking caches
geekingfrog May 21, 2024
143a631
Lobby policies
geekingfrog May 21, 2024
ce0b30f
Merge remote-tracking branch 'jauggy/jauggy/better-restriction-titles…
geekingfrog Jul 6, 2024
499009c
Merge branch 'icon-fixes-2' into merge-queue-attempt-1
geekingfrog Jul 6, 2024
f12e1f2
Merge remote-tracking branch 'jauggy/jauggy/whoami-whois-improvements…
geekingfrog Jul 6, 2024
3201139
Merge remote-tracking branch 'upstream/ReservedHostNames' into merge-…
geekingfrog Jul 6, 2024
24702e5
fix dialyzer
geekingfrog Jul 6, 2024
c6daa91
Merge branch 'init-caches' into merge-queue-attempt-1
geekingfrog Jul 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
{"lib/teiserver/account/libs/smurf_key_type_lib.ex", :unknown_type},
{"lib/teiserver/account/libs/user_lib.ex", :unknown_type},
{"lib/teiserver/account/libs/user_lib.ex", :call},
{"lib/teiserver/account/libs/user_lib.ex", :no_return},
{"lib/teiserver/account/libs/user_stat_lib.ex", :unknown_type},
{"lib/teiserver/account/plugs/auth_plug.ex", :call},
{"lib/teiserver/account/queries/friend_queries.ex", :unknown_type},
Expand Down Expand Up @@ -473,6 +474,7 @@
{"lib/teiserver/telemetry/schemas/user_property.ex", :unknown_type},
{"lib/teiserver_web/controllers/account/security_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/account/session_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/account/session_controller.ex", :pattern_match},
{"lib/teiserver_web/controllers/admin/accolade_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/admin/accolade_controller.ex", :no_return},
{"lib/teiserver_web/controllers/admin/achievement_controller.ex", :unknown_type},
Expand Down Expand Up @@ -505,6 +507,8 @@
{"lib/teiserver_web/controllers/battle/match_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/battle/ratings_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/game/queue_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/game/queue_controller.ex", :no_return},
{"lib/teiserver_web/controllers/game/queue_controller.ex", :call},
{"lib/teiserver_web/controllers/general/general_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/logging/aggregate_view_log_controller.ex", :unknown_type},
{"lib/teiserver_web/controllers/logging/aggregate_view_log_controller.ex", :no_return},
Expand Down Expand Up @@ -587,5 +591,11 @@
{"lib/teiserver_web/templates/battle/match/index.html.heex", :call},
{"lib/teiserver_web/templates/battle/match/ratings.html.heex", :no_return},
{"lib/teiserver_web/templates/battle/match/ratings.html.heex", :call},
{"lib/teiserver_web/views/admin/code_view.ex", :invalid_contract}
{"lib/teiserver_web/views/admin/code_view.ex", :invalid_contract},
{"lib/teiserver_web/live/account/profile/overview.ex", :unused_fun},
{"lib/teiserver_web/live/account/profile/overview.ex", :pattern_match},
{"test/support/teiserver_test_lib.ex", :call},
{"test/support/teiserver_test_lib.ex", :no_return},
{"test/support/teiserver_test_lib.ex", :unused_fun},
{"test/support/teiserver_test_lib.ex", :pattern_match}
]
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ jobs:

# Step: Execute the tests.
- name: Run tests
run: mix test
run: mix test --exclude needs_attention
2 changes: 1 addition & 1 deletion lib/central/general_test_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Central.Helpers.GeneralTestLib do
"name" => params["name"] || "Test",
"email" => params["email"] || "email@email#{:rand.uniform(999_999_999_999)}",
"colour" => params["colour"] || "#00AA00",
"icon" => params["icon"] || "fa-regular fa-user",
"icon" => params["icon"] || "fa-solid fa-user",
"permissions" => permissions,
"password" => params["password"] || "password",
"password_confirmation" => params["password"] || "password",
Expand Down
91 changes: 91 additions & 0 deletions lib/teiserver/account/caches/permission_cache.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
defmodule Teiserver.Account.PermissionCache do
@moduledoc """
Define caches and set them up for permission related things
"""

use Supervisor
import Teiserver.Account.AuthLib, only: [add_permission_set: 3]
alias Teiserver.Helpers.CacheHelper

def start_link(opts) do
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts),
:ok <- warm_permission_cache() do
warm_restriction_cache()
{:ok, sup}
end
end

@impl true
def init(:ok) do
children = [
CacheHelper.concache_perm_sup(:auth_group_store),
CacheHelper.concache_perm_sup(:restriction_lookup_store)
]

Supervisor.init(children, strategy: :one_for_all)
end

defp warm_permission_cache() do
add_permission_set("admin", "debug", ~w(debug))
add_permission_set("admin", "dev", ~w(developer structure))
add_permission_set("admin", "admin", ~w(limited full))
add_permission_set("admin", "report", ~w(show update delete report))
add_permission_set("admin", "user", ~w(show create update delete report))
add_permission_set("admin", "group", ~w(show create update delete report config))
add_permission_set("teiserver", "admin", ~w(account battle clan queue))

add_permission_set(
"teiserver",
"staff",
~w(overwatch reviewer moderator admin communication clan telemetry server)
)

add_permission_set("teiserver", "dev", ~w(infolog))
add_permission_set("teiserver", "reports", ~w(client server match ratings infolog))
add_permission_set("teiserver", "api", ~w(battle))

add_permission_set(
"teiserver",
"player",
~w(account tester contributor dev streamer donor verified bot moderator)
)

:ok = Teiserver.Logging.Startup.startup()

:ok
end

defp warm_restriction_cache() do
# Chat stuff
Teiserver.Account.UserLib.add_report_restriction_types("Chat", [
"Bridging",
"Game chat",
"Room chat",
"All chat"
])

# Lobby interaction
Teiserver.Account.UserLib.add_report_restriction_types("Game", [
"Low priority",
"All lobbies",
"Login",
"Permanently banned"
])

Teiserver.Account.UserLib.add_report_restriction_types("Other", [
"Accolades",
"Boss",
"Reporting",
"Renaming",
"Matchmaking"
])

Teiserver.Account.UserLib.add_report_restriction_types("Warnings", [
"Warning reminder"
])

Teiserver.Account.UserLib.add_report_restriction_types("Internal", [
"Note"
])
end
end
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/auth_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Teiserver.Account.AuthLib do
require Logger

@spec icon :: String.t()
def icon(), do: "fa-regular fa-address-card"
def icon(), do: "fa-solid fa-address-card"

@spec get_all_permission_sets() :: Map.t()
def get_all_permission_sets do
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/smurf_key_type_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Teiserver.Account.SmurfKeyTypeLib do

# Functions
@spec icon :: String.t()
def icon, do: "fa-regular fa-???"
def icon, do: "fa-regular fa-question"

@spec colours :: atom
def colours, do: :default
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/reports/mapping_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Teiserver.Game.MappingReport do
alias Teiserver.{Battle}

@spec icon() :: String.t()
def icon(), do: "fa-regular fa-map"
def icon(), do: "fa-solid fa-map"

@spec permissions() :: String.t()
def permissions(), do: "Admin"
Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/account/reports/week_on_week_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Teiserver.Account.WeekOnWeekReport do
alias Teiserver.Helper.{TimexHelper, NumberHelper}

@spec icon() :: String.t()
def icon(), do: "fa-regular fa-calendar"
def icon(), do: "fa-solid fa-calendar"

@spec permissions() :: String.t()
def permissions(), do: "Admin"
Expand Down
57 changes: 11 additions & 46 deletions lib/teiserver/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ defmodule Teiserver.Application do
alias Phoenix.PubSub
require Logger

import Teiserver.Helpers.CacheHelper,
only: [concache_sup: 1, concache_sup: 2, concache_perm_sup: 1]

@impl true
def start(_type, _args) do
# List all child processes to be supervised
Expand Down Expand Up @@ -46,18 +49,13 @@ defmodule Teiserver.Application do
concache_sup(:account_avoiding_this_cache),
concache_sup(:account_blocking_this_cache),
concache_perm_sup(:recently_used_cache),
concache_perm_sup(:auth_group_store),
concache_perm_sup(:restriction_lookup_store),
concache_perm_sup(:config_user_type_store),
concache_perm_sup(:config_site_type_store),
concache_perm_sup(:config_site_cache),
concache_perm_sup(:application_metadata_cache),
Teiserver.Account.PermissionCache,
Teiserver.Config.UserConfigTypes.Cache,
Teiserver.Config.SiteConfigTypes.Cache,
Teiserver.MetadataCache,
concache_sup(:application_temp_cache),
concache_sup(:config_user_cache),

# Tachyon schemas
concache_perm_sup(:tachyon_schemas),
concache_perm_sup(:tachyon_dispatches),
Teiserver.Tachyon.Cache,

# Teiserver stuff
# Global/singleton registries
Expand All @@ -79,8 +77,7 @@ defmodule Teiserver.Application do

# Stores - Tables where changes are not propagated across the cluster
# Possible stores
concache_perm_sup(:teiserver_queues),
concache_perm_sup(:lobby_policies_cache),
Teiserver.Data.LobbyPolicyCache,

# Telemetry
concache_perm_sup(:telemetry_property_types_cache),
Expand All @@ -98,7 +95,7 @@ defmodule Teiserver.Application do

# Caches
# Caches - Meta
concache_perm_sup(:lists),
Teiserver.Data.MatchmakingCache,

# Caches - User
# concache_sup(:users_lookup_name_with_id, [global_ttl: 300_000]),
Expand Down Expand Up @@ -135,7 +132,7 @@ defmodule Teiserver.Application do
concache_perm_sup(:discord_command_cache),

# Lobbies
concache_perm_sup(:lobby_command_cache),
Teiserver.Lobby.Cache,
{DynamicSupervisor, strategy: :one_for_one, name: Teiserver.LobbySupervisor},
{DynamicSupervisor, strategy: :one_for_one, name: Teiserver.ClientSupervisor},
{DynamicSupervisor, strategy: :one_for_one, name: Teiserver.PartySupervisor},
Expand All @@ -162,10 +159,6 @@ defmodule Teiserver.Application do
# Telemetry
{Teiserver.Telemetry.TelemetryServer, name: Teiserver.Telemetry.TelemetryServer},

# Text callbacks
concache_perm_sup(:text_callback_trigger_lookup),
concache_perm_sup(:text_callback_store),

# Ranch servers
%{
id: Teiserver.SSLSpringTcpServer,
Expand Down Expand Up @@ -206,34 +199,6 @@ defmodule Teiserver.Application do
end
end

defp concache_sup(name, opts \\ []) do
Supervisor.child_spec(
{
ConCache,
[
name: name,
ttl_check_interval: 10_000,
global_ttl: opts[:global_ttl] || 60_000,
touch_on_read: true
]
},
id: {ConCache, name}
)
end

defp concache_perm_sup(name) do
Supervisor.child_spec(
{
ConCache,
[
name: name,
ttl_check_interval: false
]
},
id: {ConCache, name}
)
end

def startup_sub_functions({:error, _}), do: :error

def startup_sub_functions(_) do
Expand Down
1 change: 1 addition & 0 deletions lib/teiserver/chat/libs/word_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ defmodule Teiserver.Chat.WordLib do
String.contains?(name, "[lm]") -> true
String.contains?(name, "[ts]") -> true
String.contains?(name, "[tei]") -> true
String.contains?(name, "Host[") -> true
true -> false
end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/teiserver/clans/schemas/clan.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
defmodule Teiserver.Clans.Clan do
use TeiserverWeb, :schema

# TODO: this type is incomplete
@type t :: %__MODULE__{
name: String.t(),
tag: String.t(),
colour: String.t(),
icon: String.t(),
description: String.t(),
rating: String.t(),
homepage: String.t()
}

schema "teiserver_clans" do
field :name, :string
field :tag, :string
Expand Down
7 changes: 7 additions & 0 deletions lib/teiserver/clans/schemas/clan_membership.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
defmodule Teiserver.Clans.ClanMembership do
use TeiserverWeb, :schema

# TODO: this type is incomplete
@type t :: %__MODULE__{
role: String.t(),
user: any(),
clan: any()
}

@primary_key false
schema "teiserver_clan_memberships" do
field :role, :string
Expand Down
25 changes: 25 additions & 0 deletions lib/teiserver/communication/libs/cache.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Teiserver.Communication.Cache do
@moduledoc """
Cache and setup for communication stuff
"""

use Supervisor
alias Teiserver.Helpers.CacheHelper

def start_link(opts) do
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts),
:ok <- Teiserver.Communication.build_text_callback_cache() do
{:ok, sup}
end
end

@impl true
def init(:ok) do
children = [
CacheHelper.concache_perm_sup(:text_callback_trigger_lookup),
CacheHelper.concache_perm_sup(:text_callback_store)
]

Supervisor.init(children, strategy: :one_for_all)
end
end
26 changes: 26 additions & 0 deletions lib/teiserver/config/site_config_types/cache.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defmodule Teiserver.Config.SiteConfigTypes.Cache do
@moduledoc """
Cache and setup for site configuration
"""

use Supervisor
alias Teiserver.Helpers.CacheHelper

def start_link(opts) do
with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts),
:ok <- Teiserver.Config.SiteConfigTypes.SystemConfigs.create(),
:ok <- Teiserver.TeiserverConfigs.teiserver_configs() do
{:ok, sup}
end
end

@impl true
def init(:ok) do
children = [
CacheHelper.concache_perm_sup(:config_site_type_store),
CacheHelper.concache_perm_sup(:config_site_cache)
]

Supervisor.init(children, strategy: :one_for_all)
end
end
Loading
Loading