Assign position directly
This commit is contained in:
parent
4a8cb71fc4
commit
2705cd0bdb
|
|
@ -119,7 +119,6 @@ class GroupStageService
|
||||||
end
|
end
|
||||||
group_scores = group_scores.sort
|
group_scores = group_scores.sort
|
||||||
|
|
||||||
ranks = []
|
|
||||||
rank = 1
|
rank = 1
|
||||||
previous = nil
|
previous = nil
|
||||||
group_scores.each_with_index do |group_score, i|
|
group_scores.each_with_index do |group_score, i|
|
||||||
|
|
@ -130,21 +129,16 @@ class GroupStageService
|
||||||
end
|
end
|
||||||
case comparison
|
case comparison
|
||||||
when 1
|
when 1
|
||||||
ranks.append i
|
group_score.position = i
|
||||||
rank = i
|
rank = i
|
||||||
when 0
|
when 0
|
||||||
ranks.append rank
|
group_score.position = rank
|
||||||
else
|
else
|
||||||
raise # should not happen, list is sorted
|
raise # should not happen, list is sorted
|
||||||
end
|
end
|
||||||
previous = group_score
|
previous = group_score
|
||||||
end
|
end
|
||||||
|
|
||||||
# assigning position is split into a second loop to not mess up the ranks by adding the position
|
|
||||||
# (which is used for sorting) too early
|
|
||||||
group_scores.each_with_index do |group_score, i|
|
|
||||||
group_score.position = ranks[i] + 1
|
|
||||||
end
|
|
||||||
group_scores
|
group_scores
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue