Add documentation to sort_group_scores

This commit is contained in:
Thor77 2019-05-14 21:43:46 +02:00
parent b307abfc43
commit d6a691fe5a
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 8 additions and 2 deletions

View File

@ -17,9 +17,15 @@ class StatisticsService
private
def sort_group_scores(groups, by)
# Sort group scores associated with `groups` by GroupScore#`attr`
# in descending order
#
# @param groups [Array] Groups to take GroupScore objects from
# @param attr [Symbol] GroupScore attribute to sort by
# @return [Array] Sorted array of group scores
def sort_group_scores(groups, attr)
groups
.map(&:group_scores).flatten # collect all group scores
.sort_by(&by).reverse
.sort_by(&attr).reverse
end
end