Commit 78c8e6b8 by Jim Abramson

Merge pull request #97 from edx/jsa/tire-match

upgrade tire to 0.5.2, update use of deprecated "text" search api
parents 590e458a 6beafbc9
...@@ -35,7 +35,7 @@ gem 'will_paginate_mongoid' ...@@ -35,7 +35,7 @@ gem 'will_paginate_mongoid'
gem 'rdiscount' gem 'rdiscount'
gem 'nokogiri' gem 'nokogiri'
gem 'tire' gem 'tire', "0.5.2"
gem 'tire-contrib' gem 'tire-contrib'
gem 'dalli' gem 'dalli'
......
...@@ -83,14 +83,14 @@ GEM ...@@ -83,14 +83,14 @@ GEM
thor (>= 0.14.6) thor (>= 0.14.6)
guard-unicorn (0.0.7) guard-unicorn (0.0.7)
guard (>= 1.1) guard (>= 1.1)
hashr (0.0.21) hashr (0.0.22)
hike (1.2.1) hike (1.2.1)
i18n (0.6.9) i18n (0.6.9)
journey (1.0.4) journey (1.0.4)
kgio (2.7.4) kgio (2.7.4)
listen (0.5.0) listen (0.5.0)
method_source (0.8) method_source (0.8)
mime-types (1.19) mime-types (2.2)
mongo (1.6.4) mongo (1.6.4)
bson (~> 1.6.4) bson (~> 1.6.4)
mongoid (3.0.15) mongoid (3.0.15)
...@@ -99,7 +99,7 @@ GEM ...@@ -99,7 +99,7 @@ GEM
origin (~> 1.0) origin (~> 1.0)
tzinfo (~> 0.3.22) tzinfo (~> 0.3.22)
moped (1.5.1) moped (1.5.1)
multi_json (1.8.2) multi_json (1.9.2)
newrelic_moped (0.0.6) newrelic_moped (0.0.6)
moped moped
newrelic_rpm (~> 3.6.0) newrelic_rpm (~> 3.6.0)
...@@ -121,7 +121,7 @@ GEM ...@@ -121,7 +121,7 @@ GEM
rack (>= 1.0) rack (>= 1.0)
rack-timeout (0.1.0beta3) rack-timeout (0.1.0beta3)
raindrops (0.10.0) raindrops (0.10.0)
rake (0.9.2.2) rake (10.2.2)
rdiscount (1.6.8) rdiscount (1.6.8)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
...@@ -148,7 +148,7 @@ GEM ...@@ -148,7 +148,7 @@ GEM
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
thor (0.16.0) thor (0.16.0)
tilt (1.3.3) tilt (1.3.3)
tire (0.4.2) tire (0.5.2)
activemodel (>= 3.0) activemodel (>= 3.0)
hashr (~> 0.0.19) hashr (~> 0.0.19)
multi_json (~> 1.0) multi_json (~> 1.0)
...@@ -202,7 +202,7 @@ DEPENDENCIES ...@@ -202,7 +202,7 @@ DEPENDENCIES
rspec rspec
simplecov simplecov
sinatra sinatra
tire tire (= 0.5.2)
tire-contrib tire-contrib
unicorn unicorn
voteable_mongo! voteable_mongo!
......
...@@ -192,7 +192,7 @@ get '/heartbeat' do ...@@ -192,7 +192,7 @@ get '/heartbeat' do
es_ok = false es_ok = false
begin begin
es_status = get_es_status es_status = get_es_status
es_ok = ( es_status["ok"] == true and es_status["status"] == 200 ) es_ok = es_status["status"] == 200
rescue rescue
end end
error 500, JSON.generate({"OK" => false, "check" => "es"}) unless es_ok error 500, JSON.generate({"OK" => false, "check" => "es"}) unless es_ok
......
...@@ -98,7 +98,7 @@ class CommentThread < Content ...@@ -98,7 +98,7 @@ class CommentThread < Content
search = Tire::Search::Search.new 'comment_threads' search = Tire::Search::Search.new 'comment_threads'
search.query {|query| query.text :_all, params["text"]} if params["text"] search.query {|query| query.match :_all, params["text"]} if params["text"]
search.highlight({title: { number_of_fragments: 0 } } , {body: { number_of_fragments: 0 } }, options: { tag: "<highlight>" }) search.highlight({title: { number_of_fragments: 0 } } , {body: { number_of_fragments: 0 } }, options: { tag: "<highlight>" })
search.filter(:term, commentable_id: params["commentable_id"]) if params["commentable_id"] search.filter(:term, commentable_id: params["commentable_id"]) if params["commentable_id"]
search.filter(:terms, commentable_id: params["commentable_ids"]) if params["commentable_ids"] search.filter(:terms, commentable_id: params["commentable_ids"]) if params["commentable_ids"]
...@@ -126,7 +126,7 @@ class CommentThread < Content ...@@ -126,7 +126,7 @@ class CommentThread < Content
if params["text"] if params["text"]
search = Tire::Search::Search.new 'comments' search = Tire::Search::Search.new 'comments'
search.query {|query| query.text :_all, params["text"]} if params["text"] search.query {|query| query.match :_all, params["text"]} if params["text"]
search.filter(:term, course_id: params["course_id"]) if params["course_id"] search.filter(:term, course_id: params["course_id"]) if params["course_id"]
search.size CommentService.config["max_deep_search_comment_count"].to_i search.size CommentService.config["max_deep_search_comment_count"].to_i
......
...@@ -106,15 +106,11 @@ describe "app" do ...@@ -106,15 +106,11 @@ describe "app" do
end end
it "reports success when es is ready" do it "reports success when es is ready" do
test_es_check({"ok" => true, "status" => 200}, true) test_es_check({"status" => 200}, true)
end
it "reports failure when es is not ok" do
test_es_check({"ok" => false, "status" => 200}, false)
end end
it "reports failure when es status is unexpected" do it "reports failure when es status is unexpected" do
test_es_check({"ok" => true, "status" => 201}, false) test_es_check({"status" => 503}, false)
end end
it "reports failure when es status is malformed" do it "reports failure when es status is malformed" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment