Skip to content
Snippets Groups Projects

Draft: Resolve "Analytics dashboard: list of users by reputation gain"

Files

@@ -66,4 +66,21 @@ module AnalyticsDashboardHelper
.count(:user_id)
.max(10) { |a, b| a[1] <=> b[1] }
end
def recent_active_users
recent_votes = Vote.where(created_at: 2.year.ago..Time.now)
user_ids = recent_votes.map(&:user_id).uniq
reps = {}
user_ids.each do |user_id|
user = User.find(user_id)
user_votes = recent_votes.where(user_id: user_id)
user_rep = Vote.total_rep_change(user_votes) + SiteSetting['NewUserInitialRep']
reps[user.username] = user_rep
end
reps.sort_by { |_, v| v }.reverse
reps.first(10)
end
end
Loading