Set default limit to 20 to improve performance

This commit is contained in:
Erik Michaels-Ober 2011-08-09 11:48:47 -07:00
parent 78e90a3283
commit f7b0c9efaa
3 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ class HydrantsController < ApplicationController
respond_to :json
def show
@hydrants = Hydrant.find_closest(params[:lat], params[:lng], params[:limit] || 50)
@hydrants = Hydrant.find_closest(params[:lat], params[:lng], params[:limit] || 20)
unless @hydrants.blank?
respond_with @hydrants
else

View File

@ -4,7 +4,7 @@ class Hydrant < ActiveRecord::Base
belongs_to :user
has_many :reminders
def self.find_closest(lat, lng, limit=50)
def self.find_closest(lat, lng, limit=20)
query = <<-SQL
SELECT *, (3959 * ACOS(COS(RADIANS(?)) * COS(RADIANS(lat)) * COS(radians(lng) - RADIANS(?)) + SIN(RADIANS(?)) * SIN(RADIANS(lat)))) AS distance
FROM hydrants

View File

@ -8,7 +8,7 @@
= select_tag "city_state", '<option value="Boston, MA" selected="selected">Boston, MA</option>'.html_safe, :tabindex => 10
= label_tag "address", "Address", :id => "address_label"
= text_field_tag "address", params[:address], :tabindex => 11
= hidden_field_tag "limit", params[:limit] || 50
= hidden_field_tag "limit", params[:limit] || 20
= submit_tag "Find fire hydrants", :tabindex => 12
#logos
= image_tag "logos/cfa.png", :alt => "Code for America", :title => "Code for America"