Skip to content

Commit

Permalink
Cleaning up the search controller a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
miketierney committed Mar 18, 2009
1 parent a1fb61f commit 8d83290
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/controllers/search_controller.rb
Expand Up @@ -19,25 +19,25 @@ def index
:order => "date ASC"
)

@lat_rads = degrees_to_radians(@ip_location[:latitude].to_f)
@long_rads = degrees_to_radians(@ip_location[:longitude].to_f)
@locations = search_locations(@query)
# @groups = Group.search(@query || "")

@groups = Group.search(@query || "")
@locations = Location.search(
(@query || ""),
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @search }
end
end

def search_locations(query)
Location.search(
(query || ""),
:geo => [
degrees_to_radians(@ip_location[:latitude].to_f),
degrees_to_radians(@ip_location[:longitude].to_f)
],
:with => { "@geodist" => 0.0..80467.2 }, # 50 miles, in meters
:without => { :start_time => 35.years.ago..Time.now }, # A little hard-coded, but it works well enough for now.
:order => "@geodist ASC"
)

respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @search }
end
end

private
Expand Down

0 comments on commit 8d83290

Please sign in to comment.