From af202716a2e5b68c5b3505218fe8ad84c3432d61 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 30 Nov 2025 20:16:46 -0800 Subject: [PATCH] add related characters endpoint --- app/controllers/api/v1/characters_controller.rb | 8 ++++++++ config/routes.rb | 2 ++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/api/v1/characters_controller.rb b/app/controllers/api/v1/characters_controller.rb index e243561..d46de15 100644 --- a/app/controllers/api/v1/characters_controller.rb +++ b/app/controllers/api/v1/characters_controller.rb @@ -11,6 +11,14 @@ module Api render json: CharacterBlueprint.render(@character, view: :full) end + def related + return render json: [] unless @character.character_id + + related = Character.where(character_id: @character.character_id) + .where.not(id: @character.id) + render json: CharacterBlueprint.render(related) + end + private def set diff --git a/config/routes.rb b/config/routes.rb index 2279e9d..132df7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,8 @@ Rails.application.routes.draw do get 'jobs/:id/skills', to: 'job_skills#job' get 'jobs/:id/accessories', to: 'job_accessories#job' + get 'characters/:id/related', to: 'characters#related' + get 'guidebooks', to: 'guidebooks#all' get 'raids', to: 'raids#all'