Move sql logic to model
Add sorted_by_rating scope to Place model
Remove unneeded sql code