Fix SQL N+1 queries with RuboCop

Database Performance