Extract top projects query object

This removed a bit of duplication from the stats controller.
Merge pull request #162 from kytrinyx/projects-stats

Extract duplicate top projects query from stats controller