hensei-api/app/blueprints/api/v1/phantom_player_blueprint.rb
Justin Edmund 5968ed74d5 add joined_at to memberships and phantoms for historical data
- editable field separate from created_at
- active_during scope uses joined_at for filtering
- backfills from created_at in migration
2025-12-04 03:02:13 -08:00

31 lines
771 B
Ruby

# frozen_string_literal: true
module Api
module V1
class PhantomPlayerBlueprint < ApiBlueprint
fields :name, :granblue_id, :notes, :claim_confirmed, :retired, :retired_at, :joined_at
field :claimed do |phantom|
phantom.claimed_by_id.present?
end
view :with_claimed_by do
field :claimed_by do |phantom|
phantom.claimed_by ? UserBlueprint.render_as_hash(phantom.claimed_by, view: :minimal) : nil
end
end
view :with_scores do
include_view :with_claimed_by
field :total_score do |phantom|
phantom.gw_individual_scores.sum(:score)
end
field :score_count do |phantom|
phantom.gw_individual_scores.count
end
end
end
end
end