diff --git a/app/models/user.rb b/app/models/user.rb index 23f3daa09d3..de6db4cc337 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -492,6 +492,10 @@ class User < ActiveRecord::Base Summarize.new(bio_cooked).summary end + def featured_user_badges + user_badges.joins(:badge).order('badges.badge_type_id ASC, badges.grant_count ASC').includes(:granted_by, badge: :badge_type).limit(3) + end + def self.count_by_signup_date(sinceDaysAgo=30) where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count end diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 1431ccd9f8b..df35418f94e 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -134,9 +134,4 @@ class UserSerializer < BasicUserSerializer def badge_count object.user_badges.count end - - def featured_user_badges - # The three rarest badges this user has received should be featured. - object.user_badges.joins(:badge).order('badges.grant_count ASC').includes(:granted_by, badge: :badge_type).limit(3) - end end