Sort featured badges by badge type first, followed by grant count.
This commit is contained in:
parent
057c56ef9b
commit
e0a4959dc9
|
@ -492,6 +492,10 @@ class User < ActiveRecord::Base
|
||||||
Summarize.new(bio_cooked).summary
|
Summarize.new(bio_cooked).summary
|
||||||
end
|
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)
|
def self.count_by_signup_date(sinceDaysAgo=30)
|
||||||
where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
|
where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
|
||||||
end
|
end
|
||||||
|
|
|
@ -134,9 +134,4 @@ class UserSerializer < BasicUserSerializer
|
||||||
def badge_count
|
def badge_count
|
||||||
object.user_badges.count
|
object.user_badges.count
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue