fix(Signature): Fixed signatures updates

This commit is contained in:
Dmitry Popov
2025-05-21 11:52:15 +02:00
parent ea29aa176f
commit 3ba8f51a2f
8 changed files with 12 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
import { SystemSignature } from '@/hooks/Mapper/types';
import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants'; import { GROUPS_LIST } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants';
import { SystemSignature } from '@/hooks/Mapper/types';
import { getState } from './getState'; import { getState } from './getState';
/** /**
@@ -22,6 +22,7 @@ export const getActualSigs = (
oldSignatures.forEach(oldSig => { oldSignatures.forEach(oldSig => {
const newSig = newSignatures.find(s => s.eve_id === oldSig.eve_id); const newSig = newSignatures.find(s => s.eve_id === oldSig.eve_id);
if (newSig) { if (newSig) {
const needUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig); const needUpgrade = getState(GROUPS_LIST, newSig) > getState(GROUPS_LIST, oldSig);
const mergedSig = { ...oldSig }; const mergedSig = { ...oldSig };

View File

@@ -1,10 +1,11 @@
import { UNKNOWN_SIGNATURE_NAME } from '@/hooks/Mapper/helpers';
import { SystemSignature } from '@/hooks/Mapper/types'; import { SystemSignature } from '@/hooks/Mapper/types';
export const getState = (_: string[], newSig: SystemSignature) => { export const getState = (_: string[], newSig: SystemSignature) => {
let state = -1; let state = -1;
if (!newSig.group) { if (!newSig.group) {
state = 0; state = 0;
} else if (!newSig.name || newSig.name === '') { } else if (!newSig.name || newSig.name === '' || newSig.name === UNKNOWN_SIGNATURE_NAME) {
state = 1; state = 1;
} else if (newSig.name !== '') { } else if (newSig.name !== '') {
state = 2; state = 2;

View File

@@ -1,8 +1,10 @@
import { SignatureGroup, SignatureKind, SystemSignature } from '@/hooks/Mapper/types';
import { import {
MAPPING_GROUP_TO_ENG, MAPPING_GROUP_TO_ENG,
MAPPING_TYPE_TO_ENG, MAPPING_TYPE_TO_ENG,
} from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts'; } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/constants.ts';
import { SignatureGroup, SignatureKind, SystemSignature } from '@/hooks/Mapper/types';
export const UNKNOWN_SIGNATURE_NAME = 'Unknown';
export const parseSignatures = (value: string, availableKeys: string[]): SystemSignature[] => { export const parseSignatures = (value: string, availableKeys: string[]): SystemSignature[] => {
const outArr: SystemSignature[] = []; const outArr: SystemSignature[] = [];
@@ -19,6 +21,7 @@ export const parseSignatures = (value: string, availableKeys: string[]): SystemS
// Extract the signature ID and check if it's valid (XXX-XXX format) // Extract the signature ID and check if it's valid (XXX-XXX format)
const sigId = sigArrInfo[0]; const sigId = sigArrInfo[0];
if (!sigId || !sigId.match(/^[A-Z]{3}-\d{3}$/)) { if (!sigId || !sigId.match(/^[A-Z]{3}-\d{3}$/)) {
continue; continue;
} }
@@ -29,6 +32,7 @@ export const parseSignatures = (value: string, availableKeys: string[]): SystemS
// Try to map the kind using the flattened mapping // Try to map the kind using the flattened mapping
const mappedKind = MAPPING_TYPE_TO_ENG[typeString]; const mappedKind = MAPPING_TYPE_TO_ENG[typeString];
if (mappedKind && availableKeys.includes(mappedKind)) { if (mappedKind && availableKeys.includes(mappedKind)) {
kind = mappedKind; kind = mappedKind;
} }
@@ -47,7 +51,7 @@ export const parseSignatures = (value: string, availableKeys: string[]): SystemS
eve_id: sigId, eve_id: sigId,
kind, kind,
group, group,
name: sigArrInfo[3] || 'Unknown', name: sigArrInfo[3] || UNKNOWN_SIGNATURE_NAME,
type: '', type: '',
}; };

View File

@@ -319,7 +319,6 @@ defmodule WandererApp.Character.Tracker do
duration = DateTime.diff(DateTime.utc_now(), error_time, :second) duration = DateTime.diff(DateTime.utc_now(), error_time, :second)
if duration >= @online_error_timeout do if duration >= @online_error_timeout do
{:ok, character_state} = WandererApp.Character.get_character_state(character_id)
WandererApp.Cache.delete("character:#{character_id}:online_forbidden") WandererApp.Cache.delete("character:#{character_id}:online_forbidden")
WandererApp.Cache.delete("character:#{character_id}:online_error_time") WandererApp.Cache.delete("character:#{character_id}:online_error_time")
WandererApp.Character.update_character(character_id, %{online: false}) WandererApp.Character.update_character(character_id, %{online: false})

View File

@@ -579,7 +579,7 @@ defmodule WandererApp.Esi.ApiClient do
end end
end end
defp maybe_cache_response(_path, _body, _headers), do: :ok defp maybe_cache_response(_path, _body, _headers, _opts), do: :ok
defp post(url, opts) do defp post(url, opts) do
try do try do

View File

@@ -11,7 +11,6 @@ defmodule WandererApp.Map.ZkbDataFetcher do
@interval :timer.seconds(15) @interval :timer.seconds(15)
@store_map_kills_timeout :timer.hours(1) @store_map_kills_timeout :timer.hours(1)
@logger Application.compile_env(:wanderer_app, :logger) @logger Application.compile_env(:wanderer_app, :logger)
@pubsub_client Application.compile_env(:wanderer_app, :pubsub_client)
# This means 120 “ticks” of 15s each → ~30 minutes # This means 120 “ticks” of 15s each → ~30 minutes
@preload_cycle_ticks 120 @preload_cycle_ticks 120

View File

@@ -3,8 +3,6 @@ defmodule WandererApp.Map.Server.AclsImpl do
require Logger require Logger
alias WandererApp.Map.Server.Impl
@pubsub_client Application.compile_env(:wanderer_app, :pubsub_client) @pubsub_client Application.compile_env(:wanderer_app, :pubsub_client)
def handle_map_acl_updated(%{map_id: map_id, map: old_map} = state, added_acls, removed_acls) do def handle_map_acl_updated(%{map_id: map_id, map: old_map} = state, added_acls, removed_acls) do
@@ -86,7 +84,7 @@ defmodule WandererApp.Map.Server.AclsImpl do
end end
end end
def handle_acl_deleted(map_id, acl_id) do def handle_acl_deleted(map_id, _acl_id) do
{:ok, map} = {:ok, map} =
WandererApp.MapRepo.get(map_id, WandererApp.MapRepo.get(map_id,
acls: [ acls: [

View File

@@ -2,15 +2,9 @@ defmodule WandererAppWeb.MapAuditAPIController do
use WandererAppWeb, :controller use WandererAppWeb, :controller
use OpenApiSpex.ControllerSpecs use OpenApiSpex.ControllerSpecs
import Ash.Query, only: [filter: 2]
require Logger require Logger
alias WandererApp.Api alias WandererApp.Api
alias WandererApp.Api.Character
alias WandererApp.MapSystemRepo
alias WandererApp.MapCharacterSettingsRepo
alias WandererApp.Zkb.KillsProvider.KillsCache
alias WandererAppWeb.Helpers.APIUtils alias WandererAppWeb.Helpers.APIUtils
@@ -158,15 +152,4 @@ defmodule WandererAppWeb.MapAuditAPIController do
) )
) )
end end
defp get_original_system_name(solar_system_id) do
# Fetch the original system name from the MapSolarSystem resource
case WandererApp.Api.MapSolarSystem.by_solar_system_id(solar_system_id) do
{:ok, system} ->
system.solar_system_name
_error ->
"Unknown System"
end
end
end end