Sort group scores correctly in backend
This commit is contained in:
parent
914584dba4
commit
86651169e9
|
|
@ -2,7 +2,17 @@
|
||||||
|
|
||||||
class GroupSerializer < ApplicationSerializer
|
class GroupSerializer < ApplicationSerializer
|
||||||
attributes :number
|
attributes :number
|
||||||
|
attributes :group_scores
|
||||||
|
|
||||||
has_many :matches
|
has_many :matches
|
||||||
has_many :group_scores
|
|
||||||
|
def group_scores
|
||||||
|
sorted_group_scores = object.group_scores.sort_by do |x|
|
||||||
|
# sort sorts from smallest to largest, therefore we need to negate the values
|
||||||
|
[
|
||||||
|
-x.group_points, -(x.scored_points - x.received_points), -x.scored_points
|
||||||
|
]
|
||||||
|
end
|
||||||
|
sorted_group_scores.map { |group_score| GroupScoreSerializer.new(group_score) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue