Refactoring leaderboard_helper

Refactoring to reduce DB calls, loops and join operation are implemented in methods.
Refactoring leaderboard

Removing some unnecessary loops.