From d6a691fe5a9edfa4f9c0e56f31d9e0513ef9a839 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Tue, 14 May 2019 21:43:46 +0200 Subject: [PATCH] Add documentation to sort_group_scores --- app/services/statistics_service.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/services/statistics_service.rb b/app/services/statistics_service.rb index 72c2b09..62ae754 100644 --- a/app/services/statistics_service.rb +++ b/app/services/statistics_service.rb @@ -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