Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def top_businesses(location, radius, category = nil)
- # Find businesses, by location, within radius, sorted by distance
- top_businesses = businesses.sort_by_distance_from(location).select {|b| b.distance < radius}
- top_businesses.reject!{|b| b.reviews.empty?}.sort_by(&:stars).reverse
- # Err...you can limit by category :)
- @businesses = @businesses.map{|b| (b.caches(:category) && (b.caches(:category).parent || b.caches(:category)).taxon_id == taxon_id) ? b : nil}.compact unless taxon_id == 0
- top_businesses.first(100)
- end
Add Comment
Please, Sign In to add comment