From ecd626f10526eebd58dd50782010f55ddcf2e615 Mon Sep 17 00:00:00 2001 From: guarzo Date: Thu, 17 Jul 2025 15:25:06 +0000 Subject: [PATCH] fix: removed unneeded api, and fixed data comparision bug --- lib/wanderer_app/api/map_transaction.ex | 18 +----------------- lib/wanderer_app/api/user_transaction.ex | 19 +------------------ lib/wanderer_app/esi/api_client.ex | 3 ++- lib/wanderer_app_web/open_api_v1_spec.ex | 4 ---- priv/posts/2025/07-15-api-modernization.md | 4 +--- 5 files changed, 5 insertions(+), 43 deletions(-) diff --git a/lib/wanderer_app/api/map_transaction.ex b/lib/wanderer_app/api/map_transaction.ex index 62279b0b..5eedb800 100644 --- a/lib/wanderer_app/api/map_transaction.ex +++ b/lib/wanderer_app/api/map_transaction.ex @@ -3,29 +3,13 @@ defmodule WandererApp.Api.MapTransaction do use Ash.Resource, domain: WandererApp.Api, - data_layer: AshPostgres.DataLayer, - extensions: [AshJsonApi.Resource] + data_layer: AshPostgres.DataLayer postgres do repo(WandererApp.Repo) table("map_transactions_v1") end - json_api do - type "map_transactions" - - includes([:map]) - - derive_filter?(true) - derive_sort?(true) - - routes do - base("/map_transactions") - get(:read) - index :read - end - end - code_interface do define(:by_id, get_by: [:id], diff --git a/lib/wanderer_app/api/user_transaction.ex b/lib/wanderer_app/api/user_transaction.ex index 27423e31..ca189973 100644 --- a/lib/wanderer_app/api/user_transaction.ex +++ b/lib/wanderer_app/api/user_transaction.ex @@ -3,30 +3,13 @@ defmodule WandererApp.Api.UserTransaction do use Ash.Resource, domain: WandererApp.Api, - data_layer: AshPostgres.DataLayer, - extensions: [AshJsonApi.Resource] + data_layer: AshPostgres.DataLayer postgres do repo(WandererApp.Repo) table("user_transaction_v1") end - json_api do - type "user_transactions" - - # Handle composite primary key - primary_key do - keys([:id]) - end - - routes do - base("/user_transactions") - - get(:read) - index :read - end - end - code_interface do define(:new, action: :new) end diff --git a/lib/wanderer_app/esi/api_client.ex b/lib/wanderer_app/esi/api_client.ex index 94f16593..19307f0b 100644 --- a/lib/wanderer_app/esi/api_client.ex +++ b/lib/wanderer_app/esi/api_client.ex @@ -789,7 +789,8 @@ defmodule WandererApp.Esi.ApiClient do scopes ) do # Log token refresh success with timing info - time_since_expiry = DateTime.diff(DateTime.utc_now(), expires_at, :second) + expires_at_datetime = DateTime.from_unix!(expires_at) + time_since_expiry = DateTime.diff(DateTime.utc_now(), expires_at_datetime, :second) Logger.info("TOKEN_REFRESH_SUCCESS: Character token refreshed successfully", character_id: character_id, diff --git a/lib/wanderer_app_web/open_api_v1_spec.ex b/lib/wanderer_app_web/open_api_v1_spec.ex index 484ca35c..dcf6ab20 100644 --- a/lib/wanderer_app_web/open_api_v1_spec.ex +++ b/lib/wanderer_app_web/open_api_v1_spec.ex @@ -68,13 +68,11 @@ defmodule WandererAppWeb.OpenApiV1Spec do %{"name" => "Map System Comments", "description" => "System comments"}, %{"name" => "Map Character Settings", "description" => "Character map settings"}, %{"name" => "Map User Settings", "description" => "User map preferences"}, - %{"name" => "Map Transactions", "description" => "Map transaction history"}, %{"name" => "Map Subscriptions", "description" => "Map subscription management"}, %{"name" => "Map Access Lists", "description" => "Map-specific ACLs"}, %{"name" => "Map States", "description" => "Map state information"}, %{"name" => "Users", "description" => "User management"}, %{"name" => "User Activities", "description" => "User activity tracking"}, - %{"name" => "User Transactions", "description" => "User transaction history"}, %{"name" => "Ship Type Info", "description" => "Ship type information"} ] end @@ -94,13 +92,11 @@ defmodule WandererAppWeb.OpenApiV1Spec do {"map_system_comments", "Map System Comments"}, {"map_character_settings", "Map Character Settings"}, {"map_user_settings", "Map User Settings"}, - {"map_transactions", "Map Transactions"}, {"map_subscriptions", "Map Subscriptions"}, {"map_access_lists", "Map Access Lists"}, {"map_states", "Map States"}, {"users", "Users"}, {"user_activities", "User Activities"}, - {"user_transactions", "User Transactions"}, {"ship_type_infos", "Ship Type Info"} ] diff --git a/priv/posts/2025/07-15-api-modernization.md b/priv/posts/2025/07-15-api-modernization.md index 987b2b79..87668c3e 100644 --- a/priv/posts/2025/07-15-api-modernization.md +++ b/priv/posts/2025/07-15-api-modernization.md @@ -115,7 +115,7 @@ Flexible sorting with offset-based pagination (available on select resources): # Sort by creation date (newest first) then by name GET /api/v1/maps?sort=-inserted_at,name -# Offset-based pagination (available on map_systems, map_system_signatures, user_activities, map_transactions) +# Offset-based pagination (available on map_systems, map_system_signatures, user_activities) GET /api/v1/map_systems?page[limit]=100&page[offset]=0 # Combined filtering, sorting, and pagination @@ -153,7 +153,6 @@ The API v1 provides access to over 25 resources through the Ash Framework. Here - **Map Connections** (`/api/v1/map_connections`) - Wormhole connections - **Map Signatures** (`/api/v1/map_system_signatures`) - Signature scanning data (GET, DELETE only) - **Map Structures** (`/api/v1/map_system_structures`) - Structure information -- **Map Transactions** (`/api/v1/map_transactions`) - Transaction history (GET only) - **Map Subscriptions** (`/api/v1/map_subscriptions`) - Subscription management (GET only) - **Map Systems and Connections** (`/api/v1/maps/{map_id}/systems_and_connections`) - Combined endpoint (GET only) @@ -162,7 +161,6 @@ The API v1 provides access to over 25 resources through the Ash Framework. Here ### User Resources - **User Activities** (`/api/v1/user_activities`) - User activity tracking (GET only) -- **User Transactions** (`/api/v1/user_transactions`) - User transaction history (GET only) - **Map Character Settings** (`/api/v1/map_character_settings`) - Character preferences (GET only) - **Map User Settings** (`/api/v1/map_user_settings`) - User map preferences (GET only)