nlake44 / UserInfuser

Gamification Platform
code.google.com/p/userinfuser
GNU Affero General Public License v3.0
102 stars 52 forks source link

Categorized rankings #2

Open kenrestivo opened 12 years ago

kenrestivo commented 12 years ago

I've been asked to display rankings per theme (used as categories) per user, on a custom leaderboard.

I'm also trying to do it without making changes to the UserInfuser codebase, or if I do need to make changes, I'd like to do them in a way that could be accepted upstream.

I'm very familiar with SQL but not with GQL. If this were SQL, I'd either do an ad-hoc join query to calculate the per-theme rankings on the fly, or perhaps create a jointable with foreign keys for user and theme, and a field for rank, and just store the rank there, joined to user.

Do you have any preference as to how this should be done, or any advice on how to do it with a minimum of change to the codebase?

Thanks.

nlake44 commented 12 years ago

The way we do it now for the single points is a query that orders by points desc and we only rank the top 1k (for scalability reasons). You can do the same but add in another field to query on. The kind will have to be separate from the users as we do it now. Here is a rough idea: SELECT * FROM PointCategory where account='me@me.com' and category='whatever' order by points DESC