Multiple queries for a leaderboard?
Hey there,
I have created an application, where users sign in and do certain activities. I wanted to make a leaderboard. There are potentially a lot of leaderboards each user could be the best at. Maybe 10? More in the future?
Anyway, I created a "hall of fame" type controller. The view has tabs, and you selected say "Most messages sent" or "Most events contributed to".
Is there a more effected way to do this than having 10 queries that look like:
$mostMessages = Users::where('messages', '>', 0)->orderBy('messages', 'desc')->take(10)->get();
$mostEvents= Users::where('events', '>', 0)->orderBy('events', 'desc')->take(10)->get();
..etc...
I'm just after the most efficient way, really!
Thanks for any advice!
Posted Aug 12, 2015, 3:34 PM UTC
15