agoragames / leaderboard

Leaderboards backed by Redis in Ruby
https://rubygems.org/gems/leaderboard
MIT License
478 stars 65 forks source link

scores_percent and scores_percent_in #66

Open dmitrypol opened 7 years ago

dmitrypol commented 7 years ago

Enables to easily get what percentage of total scores in leaderboard has this member scored (slice of the pie).
I think this could be useful to other users, please consider for inclusion in this gem.

modsognir commented 6 years ago

I'm looking for something like this. Do you know off-hand how well this performs on large datasets (>1mil)?

dmitrypol commented 6 years ago

My method is a just a wrapper around score_for_in and total_scores_in. score_for_in just calls zscore ( O(1) ). But total_scores_in might be a perf issue. I have not tested it at that scale but please let me know what you find.

modsognir commented 6 years ago

Thanks for the response, I'll give it a go!

dmitrypol commented 6 years ago

NP. I will be presenting at upcoming redisconf.com and will mention this to antirez. If there were a way for Redis to return scores of ALL members that would speed up these kinds of operations.