fix total_score to sum individual honors instead of crew scores
This commit is contained in:
parent
5968ed74d5
commit
b4f4f9c304
2 changed files with 7 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ module Api
|
||||||
fields :preliminary_ranking, :final_ranking
|
fields :preliminary_ranking, :final_ranking
|
||||||
|
|
||||||
field :total_score do |participation|
|
field :total_score do |participation|
|
||||||
participation.total_crew_score
|
participation.total_individual_honors
|
||||||
end
|
end
|
||||||
|
|
||||||
field :wins do |participation|
|
field :wins do |participation|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,16 @@ class CrewGwParticipation < ApplicationRecord
|
||||||
|
|
||||||
validates :crew_id, uniqueness: { scope: :gw_event_id, message: 'is already participating in this event' }
|
validates :crew_id, uniqueness: { scope: :gw_event_id, message: 'is already participating in this event' }
|
||||||
|
|
||||||
# Get total crew score across all rounds
|
# Get total crew score across all rounds (from crew battles)
|
||||||
def total_crew_score
|
def total_crew_score
|
||||||
gw_crew_scores.sum(:crew_score)
|
gw_crew_scores.sum(:crew_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get total individual honors (sum of all member scores)
|
||||||
|
def total_individual_honors
|
||||||
|
gw_individual_scores.sum(:score)
|
||||||
|
end
|
||||||
|
|
||||||
# Get wins count
|
# Get wins count
|
||||||
def wins_count
|
def wins_count
|
||||||
gw_crew_scores.where(victory: true).count
|
gw_crew_scores.where(victory: true).count
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue