- create gw_events, crew_gw_participations, gw_crew_scores, gw_individual_scores - add models, blueprints, controllers for GW tracking - add model specs and gw_events controller specs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
1.8 KiB
Ruby
64 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Api
|
|
module V1
|
|
class CrewGwParticipationBlueprint < ApiBlueprint
|
|
fields :preliminary_ranking, :final_ranking
|
|
|
|
field :total_score do |participation|
|
|
participation.total_crew_score
|
|
end
|
|
|
|
field :wins do |participation|
|
|
participation.wins_count
|
|
end
|
|
|
|
field :losses do |participation|
|
|
participation.losses_count
|
|
end
|
|
|
|
view :summary do
|
|
# summary uses base fields only (no gw_event)
|
|
end
|
|
|
|
view :with_event do
|
|
field :gw_event do |participation|
|
|
GwEventBlueprint.render_as_hash(participation.gw_event)
|
|
end
|
|
end
|
|
|
|
view :with_crew do
|
|
field :crew do |participation|
|
|
CrewBlueprint.render_as_hash(participation.crew, view: :minimal)
|
|
end
|
|
field :gw_event do |participation|
|
|
GwEventBlueprint.render_as_hash(participation.gw_event)
|
|
end
|
|
end
|
|
|
|
view :full do
|
|
field :gw_event do |participation|
|
|
GwEventBlueprint.render_as_hash(participation.gw_event)
|
|
end
|
|
field :crew_scores do |participation|
|
|
GwCrewScoreBlueprint.render_as_hash(participation.gw_crew_scores.order(:round))
|
|
end
|
|
end
|
|
|
|
view :with_individual_scores do
|
|
field :gw_event do |participation|
|
|
GwEventBlueprint.render_as_hash(participation.gw_event)
|
|
end
|
|
field :crew_scores do |participation|
|
|
GwCrewScoreBlueprint.render_as_hash(participation.gw_crew_scores.order(:round))
|
|
end
|
|
field :individual_scores do |participation|
|
|
GwIndividualScoreBlueprint.render_as_hash(
|
|
participation.gw_individual_scores.includes(:crew_membership).order(:round),
|
|
view: :with_member
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|