Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make search work with LIKEs.

Looks like some of Heroku servers don't have full text indices
support (untroduced in PostgreSQL 8.3).

Use LIKEs unless we'll work this issue out.
  • Loading branch information...
commit 7a6d29f16f722781d37ef4f4c5f5dc4fb37e17a7 1 parent 1947e15
beawesomeinstead authored
View
1  Gemfile
@@ -14,7 +14,6 @@ gem 'pusher', '~> 0.8.0'
gem 'refraction', '~> 0.2.0'
gem 'resque', '~> 1.15.0'
gem 'resque-meta', '~> 1.0.3'
-gem 'texticle'
gem 'travis-ci-em-pusher', '~> 0.1.1'
gem 'unobtrusive_flash', '~> 0.0.2'
gem 'yajl-ruby', '~> 0.8.2'
View
6 Gemfile.lock
@@ -96,7 +96,7 @@ GEM
faraday (0.6.0)
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
- rack (>= 1.1.0, < 2)
+ rack (< 2, >= 1.1.0)
ffi (1.0.7)
rake (>= 0.8.7)
gherkin (2.3.5)
@@ -204,10 +204,9 @@ GEM
ruby-hmac
sinatra (1.2.2)
rack (~> 1.1)
- tilt (>= 1.2.2, < 2.0)
+ tilt (< 2.0, >= 1.2.2)
term-ansicolor (1.0.5)
test_declarative (0.0.5)
- texticle (1.0.4.20101004123327)
thor (0.14.6)
tilt (1.2.2)
travis-ci-em-pusher (0.1.1)
@@ -258,7 +257,6 @@ DEPENDENCIES
ruby-debug
ruby-debug19
test_declarative
- texticle
travis-ci-em-pusher (~> 0.1.1)
unobtrusive_flash (~> 0.0.2)
web-socket-ruby
View
2  app/controllers/repositories_controller.rb
@@ -21,7 +21,7 @@ def show
protected
def repositories
repos = params[:owner_name] ? Repository.where(:owner_name => params[:owner_name]).timeline : Repository.timeline.recent
- params[:search].present? ? repos.search_generic("#{params[:search]}*") : repos
+ params[:search].present? ? repos.search(params[:search]) : repos
end
def repository
View
9 app/models/repository.rb
@@ -11,11 +11,6 @@ class Repository < ActiveRecord::Base
validates_presence_of :name, :owner_name
validates_uniqueness_of :name, :scope => :owner_name
- index("generic", "simple") do
- name
- owner_name
- end
-
class << self
def timeline
where(arel_table[:last_build_started_at].not_eq(nil)).order(arel_table[:last_build_started_at].desc)
@@ -36,6 +31,10 @@ def human_status_by(attributes)
return 'unknown' unless repository && repository.last_finished_build
repository.last_finished_build.status == 0 ? 'stable' : 'unstable'
end
+
+ def search(query)
+ where("repositories.name LIKE ? OR repositories.owner_name LIKE ?", "%#{query}%", "%#{query}%")
+ end
end
def slug
View
19 db/migrate/20110410141642_full_text_search_1302445002.rb
@@ -1,19 +0,0 @@
-class FullTextSearch1302445002 < ActiveRecord::Migration
- def self.up
- execute <<-EOSQL.strip
- DROP index IF EXISTS repositories_fts_idx
- EOSQL
-
- execute <<-EOSQL.strip
- CREATE index repositories_fts_idx
- ON repositories
- USING gin((to_tsvector('simple', coalesce("repositories"."name", '') || ' ' || coalesce("repositories"."owner_name", ''))))
- EOSQL
- end
-
- def self.down
- execute <<-EOSQL.strip
- DROP index IF EXISTS repositories_fts_idx
- EOSQL
- end
-end
View
2  db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110410141642) do
+ActiveRecord::Schema.define(:version => 20110321171101) do
create_table "builds", :force => true do |t|
t.integer "repository_id"
Please sign in to comment.
Something went wrong with that request. Please try again.