Changed distinct query to use mongoid group by