group_by ruby code example
Example: group by in ruby mongoid
Lead.where(client_id: client.id.to_s).collection.aggregate([{"$group"=>{ :_id=> "$sales_id" , :count=>{"$sum"=>1} } }, {"$match": { count: { "$gte": 3 } }} ]).to_a
Lead.where(client_id: client.id.to_s).collection.aggregate([{"$group"=>{ :_id=> "$sales_id" , :count=>{"$sum"=>1} } }, {"$match": { count: { "$gte": 3 } }} ]).to_a