From 986ef2fb5637d460e78eb9d608fec8736703fb08 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 27 Jan 2023 23:33:28 -0800 Subject: [PATCH] Add remix state and remixes to output --- app/blueprints/api/v1/party_blueprint.rb | 8 ++++++++ app/models/party.rb | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/blueprints/api/v1/party_blueprint.rb b/app/blueprints/api/v1/party_blueprint.rb index 0d118b1..a6bb8fe 100644 --- a/app/blueprints/api/v1/party_blueprint.rb +++ b/app/blueprints/api/v1/party_blueprint.rb @@ -36,6 +36,10 @@ module Api fields :name, :element, :shortcode, :favorited, :extra, :full_auto, :clear_time, :auto_guard, :created_at, :updated_at + field :remix do |p| + p.is_remix + end + association :raid, blueprint: RaidBlueprint @@ -45,6 +49,10 @@ module Api association :user, blueprint: UserBlueprint, view: :minimal + + association :remixes, + blueprint: PartyBlueprint, + view: :minimal end view :jobs do diff --git a/app/models/party.rb b/app/models/party.rb index 1b99313..6e52a5d 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -20,7 +20,7 @@ class Party < ApplicationRecord foreign_key: 'accessory_id', class_name: 'JobAccessory', optional: true - + belongs_to :skill0, foreign_key: 'skill0_id', class_name: 'JobSkill', @@ -82,6 +82,14 @@ class Party < ApplicationRecord user.favorite_parties.include? self end + def is_remix + self.source_party != nil + end + + def remixes + Party.where(source_party_id: self.id) + end + def blueprint PartyBlueprint end