mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-07 16:25:37 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cccab2a985 | ||
|
|
1abaa90a7d | ||
|
|
6e1993ca8a | ||
|
|
171c821ac4 | ||
|
|
7ebf9186bf | ||
|
|
57d2f2baef | ||
|
|
0aee13878a | ||
|
|
f93ef0ca76 | ||
|
|
4ec03d8338 |
27
CHANGELOG.md
27
CHANGELOG.md
@@ -2,6 +2,33 @@
|
||||
|
||||
<!-- changelog -->
|
||||
|
||||
## [v1.64.3](https://github.com/wanderer-industries/wanderer/compare/v1.64.2...v1.64.3) (2025-05-14)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* Core: Fixed character tracking initialization logic & removed search caching
|
||||
|
||||
## [v1.64.2](https://github.com/wanderer-industries/wanderer/compare/v1.64.1...v1.64.2) (2025-05-13)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* Core: Fixed tracking of ship & location for offline characters
|
||||
|
||||
## [v1.64.1](https://github.com/wanderer-industries/wanderer/compare/v1.64.0...v1.64.1) (2025-05-13)
|
||||
|
||||
|
||||
|
||||
|
||||
### Bug Fixes:
|
||||
|
||||
* Core: Fixed tracking stopped due to server errors
|
||||
|
||||
## [v1.64.0](https://github.com/wanderer-industries/wanderer/compare/v1.63.0...v1.64.0) (2025-05-13)
|
||||
|
||||
|
||||
|
||||
@@ -103,7 +103,9 @@ defmodule WandererApp.Character.Tracker do
|
||||
|> update_ship()
|
||||
end
|
||||
|
||||
def update_ship(%{character_id: character_id, track_ship: true} = character_state) do
|
||||
def update_ship(
|
||||
%{character_id: character_id, track_ship: true, is_online: true} = character_state
|
||||
) do
|
||||
character_id
|
||||
|> WandererApp.Character.get_character()
|
||||
|> case do
|
||||
@@ -154,7 +156,9 @@ defmodule WandererApp.Character.Tracker do
|
||||
|> update_location()
|
||||
end
|
||||
|
||||
def update_location(%{track_location: true, character_id: character_id} = character_state) do
|
||||
def update_location(
|
||||
%{track_location: true, is_online: true, character_id: character_id} = character_state
|
||||
) do
|
||||
case WandererApp.Character.get_character(character_id) do
|
||||
{:ok, %{eve_id: eve_id, access_token: access_token}} when not is_nil(access_token) ->
|
||||
WandererApp.Cache.has_key?("character:#{character_id}:location_forbidden")
|
||||
@@ -305,14 +309,9 @@ defmodule WandererApp.Character.Tracker do
|
||||
WandererApp.Cache.delete("character:#{character_id}:online_forbidden")
|
||||
WandererApp.Cache.delete("character:#{character_id}:online_error_time")
|
||||
WandererApp.Character.update_character(character_id, %{online: false})
|
||||
WandererApp.Cache.delete("character:#{character_id}:location_started")
|
||||
WandererApp.Cache.delete("character:#{character_id}:start_solar_system_id")
|
||||
|
||||
WandererApp.Character.update_character_state(character_id, %{
|
||||
character_state
|
||||
| is_online: false,
|
||||
track_ship: false,
|
||||
track_location: false
|
||||
is_online: false
|
||||
})
|
||||
|
||||
:ok
|
||||
|
||||
@@ -34,6 +34,7 @@ defmodule WandererApp.Character.TrackerManager.Impl do
|
||||
|
||||
def start(state) do
|
||||
{:ok, tracked_characters} = WandererApp.Cache.lookup("tracked_characters", [])
|
||||
WandererApp.Cache.insert("tracked_characters", [])
|
||||
|
||||
tracked_characters
|
||||
|> Enum.each(fn character_id ->
|
||||
@@ -51,6 +52,12 @@ defmodule WandererApp.Character.TrackerManager.Impl do
|
||||
tracked_characters = [character_id | characters] |> Enum.uniq()
|
||||
WandererApp.Cache.insert("tracked_characters", tracked_characters)
|
||||
|
||||
WandererApp.Character.update_character(character_id, %{online: false})
|
||||
|
||||
WandererApp.Character.update_character_state(character_id, %{
|
||||
is_online: false
|
||||
})
|
||||
|
||||
WandererApp.Character.TrackerPoolDynamicSupervisor.start_tracking(character_id)
|
||||
|
||||
WandererApp.TaskWrapper.start_link(WandererApp.Character, :update_character_state, [
|
||||
|
||||
@@ -177,6 +177,10 @@ defmodule WandererApp.Character.TrackerPool do
|
||||
characters
|
||||
|> Enum.each(fn character_id ->
|
||||
WandererApp.Character.update_character(character_id, %{online: false})
|
||||
|
||||
WandererApp.Character.update_character_state(character_id, %{
|
||||
is_online: false
|
||||
})
|
||||
end)
|
||||
|
||||
{:noreply, state}
|
||||
|
||||
@@ -102,7 +102,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
{:ok, []}
|
||||
end
|
||||
|
||||
chains = _remove_intersection([map_chains | thera_chains] |> List.flatten())
|
||||
chains = remove_intersection([map_chains | thera_chains] |> List.flatten())
|
||||
|
||||
chains =
|
||||
case routes_settings.include_cruise do
|
||||
@@ -302,7 +302,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
opts: [ttl: @ttl]
|
||||
)
|
||||
def get_killmail(killmail_id, killmail_hash, opts \\ []) do
|
||||
get("/killmails/#{killmail_id}/#{killmail_hash}/", opts)
|
||||
get("/killmails/#{killmail_id}/#{killmail_hash}/", opts, @cache_opts)
|
||||
end
|
||||
|
||||
@decorate cacheable(
|
||||
@@ -325,7 +325,8 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
def get_character_info(eve_id, opts \\ []) do
|
||||
case get(
|
||||
"/characters/#{eve_id}/",
|
||||
opts
|
||||
opts,
|
||||
@cache_opts
|
||||
) do
|
||||
{:ok, result} -> {:ok, result |> Map.put("eve_id", eve_id)}
|
||||
{:error, error} -> {:error, error}
|
||||
@@ -339,25 +340,35 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
def get_custom_route_base_url, do: WandererApp.Env.custom_route_base_url()
|
||||
|
||||
def get_character_wallet(character_eve_id, opts \\ []),
|
||||
do: _get_character_auth_data(character_eve_id, "wallet", opts)
|
||||
do: get_character_auth_data(character_eve_id, "wallet", opts ++ @cache_opts)
|
||||
|
||||
def get_corporation_wallets(corporation_id, opts \\ []),
|
||||
do: _get_corporation_auth_data(corporation_id, "wallets", opts)
|
||||
do: get_corporation_auth_data(corporation_id, "wallets", opts)
|
||||
|
||||
def get_corporation_wallet_journal(corporation_id, division, opts \\ []),
|
||||
do: _get_corporation_auth_data(corporation_id, "wallets/#{division}/journal", opts)
|
||||
do:
|
||||
get_corporation_auth_data(
|
||||
corporation_id,
|
||||
"wallets/#{division}/journal",
|
||||
opts
|
||||
)
|
||||
|
||||
def get_corporation_wallet_transactions(corporation_id, division, opts \\ []),
|
||||
do: _get_corporation_auth_data(corporation_id, "wallets/#{division}/transactions", opts)
|
||||
do:
|
||||
get_corporation_auth_data(
|
||||
corporation_id,
|
||||
"wallets/#{division}/transactions",
|
||||
opts
|
||||
)
|
||||
|
||||
def get_character_location(character_eve_id, opts \\ []),
|
||||
do: _get_character_auth_data(character_eve_id, "location", opts)
|
||||
do: get_character_auth_data(character_eve_id, "location", opts ++ @cache_opts)
|
||||
|
||||
def get_character_online(character_eve_id, opts \\ []),
|
||||
do: _get_character_auth_data(character_eve_id, "online", opts)
|
||||
do: get_character_auth_data(character_eve_id, "online", opts ++ @cache_opts)
|
||||
|
||||
def get_character_ship(character_eve_id, opts \\ []),
|
||||
do: _get_character_auth_data(character_eve_id, "ship", opts)
|
||||
do: get_character_auth_data(character_eve_id, "ship", opts ++ @cache_opts)
|
||||
|
||||
def search(character_eve_id, opts \\ []) do
|
||||
search_val = to_string(opts[:params][:search] || "")
|
||||
@@ -372,7 +383,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
]
|
||||
|
||||
merged_opts = Keyword.put(opts, :params, query_params)
|
||||
_search(character_eve_id, search_val, categories_val, merged_opts)
|
||||
get_search(character_eve_id, search_val, categories_val, merged_opts)
|
||||
end
|
||||
|
||||
@decorate cacheable(
|
||||
@@ -380,11 +391,11 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
key: "search-#{character_eve_id}-#{categories_val}-#{search_val |> Slug.slugify()}",
|
||||
opts: [ttl: @ttl]
|
||||
)
|
||||
defp _search(character_eve_id, search_val, categories_val, merged_opts) do
|
||||
_get_character_auth_data(character_eve_id, "search", merged_opts)
|
||||
defp get_search(character_eve_id, search_val, categories_val, merged_opts) do
|
||||
get_character_auth_data(character_eve_id, "search", merged_opts)
|
||||
end
|
||||
|
||||
defp _remove_intersection(pairs_arr) do
|
||||
defp remove_intersection(pairs_arr) do
|
||||
tuples = pairs_arr |> Enum.map(fn x -> {x.first, x.second} end)
|
||||
|
||||
tuples
|
||||
@@ -405,9 +416,9 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
end
|
||||
|
||||
defp _get_routes(origin, destination, params, opts),
|
||||
do: _get_routes_eve(origin, destination, params, opts)
|
||||
do: get_routes_eve(origin, destination, params, opts)
|
||||
|
||||
defp _get_routes_eve(origin, destination, params, opts) do
|
||||
defp get_routes_eve(origin, destination, params, opts) do
|
||||
esi_params =
|
||||
Map.merge(params, %{
|
||||
connections: params.connections |> Enum.join(","),
|
||||
@@ -416,7 +427,8 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
|
||||
get(
|
||||
"/route/#{origin}/#{destination}/?#{esi_params |> Plug.Conn.Query.encode()}",
|
||||
opts
|
||||
opts,
|
||||
@cache_opts
|
||||
)
|
||||
end
|
||||
|
||||
@@ -426,17 +438,19 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
do:
|
||||
get(
|
||||
"/alliances/#{alliance_eve_id}/#{info_path}",
|
||||
opts
|
||||
opts,
|
||||
@cache_opts
|
||||
)
|
||||
|
||||
defp _get_corporation_info(corporation_eve_id, info_path, opts),
|
||||
do:
|
||||
get(
|
||||
"/corporations/#{corporation_eve_id}/#{info_path}",
|
||||
opts
|
||||
opts,
|
||||
@cache_opts
|
||||
)
|
||||
|
||||
defp _get_character_auth_data(character_eve_id, info_path, opts) do
|
||||
defp get_character_auth_data(character_eve_id, info_path, opts) do
|
||||
path = "/characters/#{character_eve_id}/#{info_path}"
|
||||
|
||||
auth_opts =
|
||||
@@ -445,7 +459,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
|
||||
character_id = opts |> Keyword.get(:character_id, nil)
|
||||
|
||||
if not _is_access_token_expired?(character_id) do
|
||||
if not is_access_token_expired?(character_id) do
|
||||
get(
|
||||
path,
|
||||
auth_opts,
|
||||
@@ -456,7 +470,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
end
|
||||
end
|
||||
|
||||
defp _is_access_token_expired?(character_id) do
|
||||
defp is_access_token_expired?(character_id) do
|
||||
{:ok, %{expires_at: expires_at} = _character} =
|
||||
WandererApp.Character.get_character(character_id)
|
||||
|
||||
@@ -465,13 +479,13 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
expires_at - now <= 0
|
||||
end
|
||||
|
||||
defp _get_corporation_auth_data(corporation_eve_id, info_path, opts),
|
||||
defp get_corporation_auth_data(corporation_eve_id, info_path, opts),
|
||||
do:
|
||||
get(
|
||||
"/corporations/#{corporation_eve_id}/#{info_path}",
|
||||
[params: opts[:params] || []] ++
|
||||
(opts |> get_auth_opts()),
|
||||
opts
|
||||
opts ++ @cache_opts
|
||||
)
|
||||
|
||||
defp with_user_agent_opts(opts) do
|
||||
@@ -513,7 +527,7 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
|> Keyword.merge(@timeout_opts)
|
||||
) do
|
||||
{:ok, %{status: 200, body: body, headers: headers}} ->
|
||||
maybe_cache_response(path, body, headers)
|
||||
maybe_cache_response(path, body, headers, opts)
|
||||
|
||||
{:ok, body}
|
||||
|
||||
@@ -530,11 +544,9 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
get_retry(path, api_opts, opts, :error_limited)
|
||||
|
||||
{:ok, %{status: status}} ->
|
||||
IO.inspect(status)
|
||||
{:error, "Unexpected status: #{status}"}
|
||||
|
||||
{:error, _reason} ->
|
||||
IO.inspect(_reason)
|
||||
{:error, "Request failed"}
|
||||
end
|
||||
rescue
|
||||
@@ -545,18 +557,20 @@ defmodule WandererApp.Esi.ApiClient do
|
||||
end
|
||||
end
|
||||
|
||||
defp maybe_cache_response(path, body, %{"expires" => [expires]})
|
||||
defp maybe_cache_response(path, body, %{"expires" => [expires]}, opts)
|
||||
when is_binary(path) and not is_nil(expires) do
|
||||
try do
|
||||
cached_ttl =
|
||||
DateTime.diff(Timex.parse!(expires, "{RFC1123}"), DateTime.utc_now(), :millisecond)
|
||||
if opts |> Keyword.get(:cache, false) do
|
||||
cached_ttl =
|
||||
DateTime.diff(Timex.parse!(expires, "{RFC1123}"), DateTime.utc_now(), :millisecond)
|
||||
|
||||
Cachex.put(
|
||||
:api_cache,
|
||||
path,
|
||||
body,
|
||||
ttl: cached_ttl
|
||||
)
|
||||
Cachex.put(
|
||||
:api_cache,
|
||||
path,
|
||||
body,
|
||||
ttl: cached_ttl
|
||||
)
|
||||
end
|
||||
rescue
|
||||
e ->
|
||||
@logger.error(Exception.message(e))
|
||||
|
||||
Reference in New Issue
Block a user