Guest User

Untitled

a guest
Apr 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. def top_businesses(location, radius, category = nil)
  2. # Find businesses, by location, within radius, sorted by distance
  3. top_businesses = businesses.sort_by_distance_from(location).select {|b| b.distance < radius}
  4.  
  5. top_businesses.reject!{|b| b.reviews.empty?}.sort_by(&:stars).reverse
  6.  
  7. # Err...you can limit by category :)
  8. @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
  9.  
  10. top_businesses.first(100)
  11. end
Add Comment
Please, Sign In to add comment