diff --git a/app/models/concerns/reputationable.rb b/app/models/concerns/reputationable.rb index 59f8a4da614b28dad688ca6336de23b421cb8129..13697eb0598d3d444a80c563fbda111c29bb1412 100644 --- a/app/models/concerns/reputationable.rb +++ b/app/models/concerns/reputationable.rb @@ -1,6 +1,10 @@ module Reputationable extend ActiveSupport::Concern + included do + delegate :count, to: :followers, prefix: true + end + def submitted_objects learning_objects.count end @@ -8,7 +12,7 @@ module Reputationable def reviews_score_average scores = learning_objects.map(&:review_ratings_average) - return 0.0 if scores.size == 0 + return 0.0 if scores.empty? scores.inject(0.0) { |a, e| a + e }.to_f / scores.size.to_f end @@ -35,14 +39,10 @@ module Reputationable array.inject(0.0) { |a, e| a + e } / array.size end - def followers_count - followers.count - end - def learning_objects_recently_submitted return 0.0 if learning_objects.nil? - learning_objects.where('created_at >= ?', (Time.now - 2.months)).count + learning_objects.where('created_at >= ?', (Time.current - 2.months)).count end def collections_score_average