Hey all,
I have a database with columns (username, points). I am making a call to return some fields from this database to use in a program. I want to pull:
- The top 10 users with the most points
- The 5 users above/below the username requesting the rankings
I can pull the top 10 easily enough...
top_users = UserPoints.find(
:all,
:conditions => ['points > 0'],
:order => "points DESC",
:limit => 10)
Pulling the specific entry for the username requesting is also easy with find_by_username, but how could I determine where this user is ranked? Then, how would you go about finding the 5 users above and 5 users below the specific user (assuming the user is not in the top 10)?
Thanks!
-mark