Count of badges on user page?

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.

5 Likes

1 Like

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 :slight_smile:

I would really really like this too.

Ruby is a weird foreign language to me, and SQL beyond simple SELECT and maybe GROUP BY gives me hives, but … as I understand it, the things in the user page can be those from the directory_items table, which is constructed by SUMming and COUNTing things in various user tables, in directory_item.rb.

In user_stat.rb, I find a distinct_badge_count, which would be fine if this were for all time, but we want the various leaderboard time periods, and also for this purpose probably don’t want distinct anyway.

I think maybe all that’s needed is to add to the gigantic SQL query to count from user_badges where the granted_at date is after since?

Oh, although I guess also it needs to check and only count the badges that are enabled.

2 Likes

I’m not sure about the technical difficulty of adding badge counts to the users page, but now that we allow optional directory items to be added to the users page, it seems that badge counts would be a logical addition. It would help to make the users page function more as a leaderboard.

Just a thought, but would adding a badges_received column to directory_items be a possible way of approaching the issue?

2 Likes

I’m looking for an all time count, so thanks to your direction I pulled this query from the user_stat.rb and ran it in the data explorer and it gave me a list of all users with their badge count:

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
1 Like