Make queries more efficient by removing n+1 queries

Hi,
I saw that we gitlab did some n+1 queries, so in this pull request I have added bullet gem for detecting those n+1 queries.

And I have fixed some of the queries from the dashboard and issues view.