Use methods instead of attributes
because each attribute is only used once and updating a Stage should reflect those changes
This commit is contained in:
parent
d6a691fe5a
commit
37b63cace2
|
|
@ -5,15 +5,19 @@ class StatisticsService
|
||||||
raise 'Unsupported stage type' if stage.nil? || stage.groups.empty?
|
raise 'Unsupported stage type' if stage.nil? || stage.groups.empty?
|
||||||
|
|
||||||
@stage = stage
|
@stage = stage
|
||||||
@group_scores = sort_group_scores(@stage.groups, :group_points)
|
|
||||||
|
|
||||||
@most_dominant_score = sort_group_scores(@stage.groups, :scored_points).first
|
|
||||||
@least_dominant_score = sort_group_scores(@stage.groups, :received_points).first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :group_scores
|
def group_scores
|
||||||
attr_reader :most_dominant_score
|
sort_group_scores(@stage.groups, :group_points)
|
||||||
attr_reader :least_dominant_score
|
end
|
||||||
|
|
||||||
|
def most_dominant_score
|
||||||
|
sort_group_scores(@stage.groups, :scored_points).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def least_dominant_score
|
||||||
|
sort_group_scores(@stage.groups, :received_points).first
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue