mirror of
https://github.com/wanderer-industries/wanderer
synced 2026-08-24 06:46:30 +00:00
fix(core): fixed character tracking issues
This commit is contained in:
+16
-7
@@ -134,12 +134,21 @@ defmodule WandererApp.Map do
|
||||
def get_options(map_id),
|
||||
do: {:ok, map_id |> get_map!() |> Map.get(:options, Map.new())}
|
||||
|
||||
def get_character_ids(map_id),
|
||||
do:
|
||||
{:ok,
|
||||
map_id
|
||||
|> get_map!()
|
||||
|> Map.get(:characters, [])}
|
||||
def get_tracked_character_ids(map_id) do
|
||||
{:ok,
|
||||
map_id
|
||||
|> get_map!()
|
||||
|> Map.get(:characters, [])
|
||||
|> Enum.filter(fn character_id ->
|
||||
{:ok, tracking_start_time} =
|
||||
WandererApp.Cache.lookup(
|
||||
"character:#{character_id}:map:#{map_id}:tracking_start_time",
|
||||
nil
|
||||
)
|
||||
|
||||
not is_nil(tracking_start_time)
|
||||
end)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns a full list of characters in the map
|
||||
@@ -233,7 +242,7 @@ defmodule WandererApp.Map do
|
||||
:ok
|
||||
|
||||
_ ->
|
||||
{:error, :already_exists}
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -214,9 +214,9 @@ defmodule WandererApp.Map.Server.CharactersImpl do
|
||||
start_time = System.monotonic_time(:microsecond)
|
||||
|
||||
try do
|
||||
{:ok, active_character_ids} = WandererApp.Map.get_character_ids(map_id)
|
||||
{:ok, tracked_character_ids} = WandererApp.Map.get_tracked_character_ids(map_id)
|
||||
|
||||
character_count = length(active_character_ids)
|
||||
character_count = length(tracked_character_ids)
|
||||
|
||||
# Emit telemetry for tracking update cycle start
|
||||
:telemetry.execute(
|
||||
@@ -229,7 +229,7 @@ defmodule WandererApp.Map.Server.CharactersImpl do
|
||||
max_concurrency = calculate_max_concurrency(character_count)
|
||||
|
||||
updated_characters =
|
||||
active_character_ids
|
||||
tracked_character_ids
|
||||
|> Task.async_stream(
|
||||
fn character_id ->
|
||||
# Use batch cache operations for all character tracking data
|
||||
|
||||
Reference in New Issue
Block a user