Skip to content

Commit

Permalink
Added indexes to categories to try and improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
driki committed Mar 14, 2012
1 parent fdde236 commit 4dffabe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ gem 'refraction'
gem 'factory_girl_rails'
gem 'awesome_nested_set'
gem 'roar-rails'
gem 'typhoeus'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ GEM
polyglot (>= 0.3.1)
turn (0.8.2)
ansi (>= 1.2.2)
typhoeus (0.3.3)
mime-types
tzinfo (0.3.31)
uglifier (1.2.2)
execjs (>= 0.3.0)
Expand Down Expand Up @@ -268,4 +270,5 @@ DEPENDENCIES
sqlite3
tabs_on_rails
turn (= 0.8.2)
typhoeus
uglifier (>= 1.0.3)
9 changes: 9 additions & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def load_official_website
end
end

def determine_website_vendor
# CivicPlus
if Typhoeus::Request.head("#{self.website}Archive.aspx").code == 200
return "CIVIC_PLUS"
else
return "UNKNOWN"
end
end

def self.load_census(state_abbriviation)
api_key = "8gybnk94e8uyt5vzv9enzpyz"
url = "http://api.usatoday.com/open/census/loc?keypat=#{state_abbriviation}&sumlevid=4,6&api_key=#{api_key}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIsExpenseIndexToCategories < ActiveRecord::Migration
def change
add_index :categories, :is_expense
end
end
5 changes: 5 additions & 0 deletions db/migrate/20120314130112_add_ancestry_index_to_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAncestryIndexToCategories < ActiveRecord::Migration
def change
add_index :categories, :ancestry
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120221004024) do
ActiveRecord::Schema.define(:version => 20120314130112) do

create_table "categories", :force => true do |t|
t.string "name"
Expand All @@ -29,6 +29,9 @@
t.boolean "is_expense", :default => true
end

add_index "categories", ["ancestry"], :name => "index_categories_on_ancestry"
add_index "categories", ["is_expense"], :name => "index_categories_on_is_expense"

create_table "forecasts", :force => true do |t|
t.string "name"
t.text "description"
Expand Down

0 comments on commit 4dffabe

Please sign in to comment.