manifoldmarkets / manifold

Manifold Markets: A market for every question
https://manifold.markets
MIT License
418 stars 157 forks source link

Feature request: Top Followed users leaderboard #527

Closed bcongdon closed 2 years ago

bcongdon commented 2 years ago

It'd be nice to have a leaderboard with the top followed users. -- I'd be interested in working on this.

My understanding is that Firebase doesn't easily allow for aggregation queries (e.g. SELECT user, COUNT(*) FROM follows GROUP BY user), so this is nontrivial.

One approach would be to:

  1. Add a followersCached property to the User document (similar to creatorVolumeCached)
  2. Increment/decrement this cached value upon follow/unfollow.
  3. Backfill this value for existing users.
  4. Base the leaderboard off of followersCached.

Does this seem reasonable?

(See also https://manifold.markets/ScottLawrence/will-manifold-create-a-leaderboard)

jahooma commented 2 years ago

Yes! That's a good approach. If you don't want to write a backfilling script, you could query for the followers on every follow / unfollow, count them, and set followersCached on the user.

I tend to like verbose names, but you might try followerCountCached instead, so it doesn't sound like a list of followers. Also, I'm not sure you really need the Cached postfix after all. So I'd go with just followerCount.