mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-07 16:25:37 +00:00
* fix(Map): fix design of kills widget, fix design of signatures widget - refactor a lot of code, fixed problem with tooltip blinking * fix(Map): refactor Tracking dialog, refactor Activity tracker, refactor codebase and some styles * fix(Core): don't count character passage on manual add connection * refactor(Core): improved characters tracking API * fix(Core): fixed link signature to system on 'leads to' set * fix(Map): Refactor map settings and prepared it to easier using * fix(Map): Add support new command for following update * fix(Map): Add support new command for main update * refactor(Core): Reduce map init data by using cached system static data * refactor(Core): Reduce map init data by extract signatures loading to a separate event * fix(Core): adjusted IP rate limits * fix(Map): Update design of tracking characters. Added icons for following and main. Added ability to see that character on the station or structure --------- Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai> Co-authored-by: Dmitry Popov <dmitriypopovsamara@gmail.com>
147 lines
3.8 KiB
Elixir
147 lines
3.8 KiB
Elixir
defmodule WandererApp.Api.MapCharacterSettings do
|
|
@moduledoc false
|
|
|
|
use Ash.Resource,
|
|
domain: WandererApp.Api,
|
|
data_layer: AshPostgres.DataLayer
|
|
|
|
postgres do
|
|
repo(WandererApp.Repo)
|
|
table("map_character_settings_v1")
|
|
end
|
|
|
|
code_interface do
|
|
define(:create, action: :create)
|
|
define(:destroy, action: :destroy)
|
|
|
|
define(:read_by_map, action: :read_by_map)
|
|
define(:by_map_filtered, action: :by_map_filtered)
|
|
define(:tracked_by_map_filtered, action: :tracked_by_map_filtered)
|
|
define(:tracked_by_map_all, action: :tracked_by_map_all)
|
|
|
|
define(:track, action: :track)
|
|
define(:untrack, action: :untrack)
|
|
|
|
define(:follow, action: :follow)
|
|
define(:unfollow, action: :unfollow)
|
|
end
|
|
|
|
actions do
|
|
default_accept [
|
|
:map_id,
|
|
:character_id,
|
|
:tracked
|
|
]
|
|
|
|
defaults [:create, :read, :update, :destroy]
|
|
|
|
read :by_map_filtered do
|
|
argument(:map_id, :string, allow_nil?: false)
|
|
argument(:character_ids, {:array, :uuid}, allow_nil?: false)
|
|
|
|
filter(expr(map_id == ^arg(:map_id) and character_id in ^arg(:character_ids)))
|
|
end
|
|
|
|
read :tracked_by_map_filtered do
|
|
argument(:map_id, :string, allow_nil?: false)
|
|
argument(:character_ids, {:array, :uuid}, allow_nil?: false)
|
|
|
|
filter(
|
|
expr(map_id == ^arg(:map_id) and tracked == true and character_id in ^arg(:character_ids))
|
|
)
|
|
end
|
|
|
|
read :read_by_map do
|
|
argument(:map_id, :string, allow_nil?: false)
|
|
filter(expr(map_id == ^arg(:map_id)))
|
|
end
|
|
|
|
read :tracked_by_map_all do
|
|
argument(:map_id, :string, allow_nil?: false)
|
|
filter(expr(map_id == ^arg(:map_id) and tracked == true))
|
|
end
|
|
|
|
update :track do
|
|
accept [:map_id, :character_id]
|
|
argument :map_id, :string, allow_nil?: false
|
|
argument :character_id, :uuid, allow_nil?: false
|
|
|
|
# Load the record first
|
|
load do
|
|
filter expr(map_id == ^arg(:map_id) and character_id == ^arg(:character_id))
|
|
end
|
|
|
|
# Only update the tracked field
|
|
change set_attribute(:tracked, true)
|
|
end
|
|
|
|
update :untrack do
|
|
accept [:map_id, :character_id]
|
|
argument :map_id, :string, allow_nil?: false
|
|
argument :character_id, :uuid, allow_nil?: false
|
|
|
|
# Load the record first
|
|
load do
|
|
filter expr(map_id == ^arg(:map_id) and character_id == ^arg(:character_id))
|
|
end
|
|
|
|
# Only update the tracked field
|
|
change set_attribute(:tracked, false)
|
|
end
|
|
|
|
update :follow do
|
|
accept [:map_id, :character_id]
|
|
argument :map_id, :string, allow_nil?: false
|
|
argument :character_id, :uuid, allow_nil?: false
|
|
|
|
# Load the record first
|
|
load do
|
|
filter expr(map_id == ^arg(:map_id) and character_id == ^arg(:character_id))
|
|
end
|
|
|
|
# Only update the followed field
|
|
change set_attribute(:followed, true)
|
|
end
|
|
|
|
update :unfollow do
|
|
accept [:map_id, :character_id]
|
|
argument :map_id, :string, allow_nil?: false
|
|
argument :character_id, :uuid, allow_nil?: false
|
|
|
|
# Load the record first
|
|
load do
|
|
filter expr(map_id == ^arg(:map_id) and character_id == ^arg(:character_id))
|
|
end
|
|
|
|
# Only update the followed field
|
|
change set_attribute(:followed, false)
|
|
end
|
|
end
|
|
|
|
attributes do
|
|
uuid_primary_key :id
|
|
|
|
attribute :tracked, :boolean do
|
|
default false
|
|
allow_nil? true
|
|
end
|
|
|
|
attribute :followed, :boolean do
|
|
default false
|
|
allow_nil? true
|
|
end
|
|
|
|
create_timestamp(:inserted_at)
|
|
update_timestamp(:updated_at)
|
|
end
|
|
|
|
relationships do
|
|
belongs_to :map, WandererApp.Api.Map, primary_key?: true, allow_nil?: false
|
|
belongs_to :character, WandererApp.Api.Character, primary_key?: true, allow_nil?: false
|
|
end
|
|
|
|
identities do
|
|
identity :uniq_map_character, [:map_id, :character_id]
|
|
end
|
|
end
|