Would it be possible to get a column added for badge count? I have a lot of badge…um…hounds, yeah that’s the PC word, and they want to see at a glance who is in the lead in terms of collecting the most badges.
It’s not planned or on any roadmaps at the moment.
Thanks for the info - has anyone else asked for something like this, to your knowledge, or am I the lone requestor 
我也 非常非常 想要这个。
Ruby 对我来说是一种奇怪的外语,SQL 除了简单的 SELECT 和可能还有 GROUP BY 之外,都会让我感到不适,但是……据我所知,用户页面中的内容可以来自 directory_items 表,该表是通过 SUMming 和 COUNTing 各种用户表中的内容来构建的,具体请参见 directory_item.rb。
在 user_stat.rb 中,我找到了 distinct_badge_count,如果这是针对所有时间的话,那倒是可以,但我们需要的是各种排行榜的时间段,而且出于这个目的,可能也不需要 distinct。
我 认为 也许只需要在巨大的 SQL 查询中添加一个条件,从 user_badges 中计数,其中 granted_at 日期在 since 之后?
哦,不过我也猜到,还需要检查并只计算已启用的徽章。
我不确定在用户页面添加徽章计数的技术难度,但既然我们允许向用户页面添加可选的目录项,那么添加徽章计数似乎是合乎逻辑的。这将有助于使用户页面更像一个排行榜。
这只是一个想法,但向 directory_items 添加 badges_received 列是否是解决此问题的一种可能方法?
我正在寻找一个总计计数,所以感谢您的指导,我从 user_stat.rb 中提取了此查询并在数据浏览器中运行了它,它给了我一个包含所有用户及其徽章计数的列表:
SELECT users.id user_id, COUNT(distinct user_badges.badge_id) distinct_badge_count
FROM users
LEFT JOIN user_badges ON user_badges.user_id = users.id
AND (user_badges.badge_id IN (SELECT id FROM badges WHERE enabled))
GROUP BY users.id
ORDER BY distinct_badge_count DESC