inquisitio 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/inquisitio/searcher.rb +3 -1
- data/lib/inquisitio/version.rb +1 -1
- data/test/results_test.rb +13 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab2d4cf939da96f26e1f9ad688363f9df23ed697
|
4
|
+
data.tar.gz: 865070d56b16d662a21a5ea2ae6deb823757cde6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2458344374731f34cfbfa78c9c662dcf285303cd4a9ff004b5af23693d4cbbd8c2a4ea01cacacf27a1e86c591adf917659c548df00a0a93de1ba87ba9c037ab
|
7
|
+
data.tar.gz: e13822c322f83c5d49911505930d4ca05e05c3eddb3f72a4fde1182fc75960d9b83b0df5ec73d19fed22f05deb4753ac6f8a3cd4484f5524355b25851a95ea12
|
data/CHANGELOG.md
CHANGED
data/lib/inquisitio/searcher.rb
CHANGED
@@ -125,11 +125,13 @@ module Inquisitio
|
|
125
125
|
response = Excon.get(search_url)
|
126
126
|
raise InquisitioError.new("Search failed with status code: #{response.status} Message #{response.body}") unless response.status == 200
|
127
127
|
body = JSON.parse(response.body)
|
128
|
+
time_ms = body['info']['time-ms'] if Inquisitio.config.api_version == '2011-02-01'
|
129
|
+
time_ms = body['status']['time-ms'] if Inquisitio.config.api_version == '2013-01-01'
|
128
130
|
@results = Results.new(body['hits']['hit'],
|
129
131
|
params[:page],
|
130
132
|
params[:per],
|
131
133
|
body['hits']['found'],
|
132
|
-
|
134
|
+
time_ms)
|
133
135
|
rescue => e
|
134
136
|
@failed_attempts += 1
|
135
137
|
Inquisitio.config.logger.error("Exception Performing search: #{search_url} #{e}")
|
data/lib/inquisitio/version.rb
CHANGED
data/test/results_test.rb
CHANGED
@@ -6,6 +6,7 @@ module Inquisitio
|
|
6
6
|
super
|
7
7
|
@search_endpoint = 'http://my.search-endpoint.com'
|
8
8
|
Inquisitio.config.search_endpoint = @search_endpoint
|
9
|
+
Inquisitio.config.api_version = nil
|
9
10
|
@result_1 = {'data' => {'id' => ['1'], 'title' => ["Foobar"], 'type' => ["Cat"]}}
|
10
11
|
@result_2 = {'data' => {'id' => ['2'], 'title' => ["Foobar"], 'type' => ["Cat"]}}
|
11
12
|
@result_3 = {'data' => {'id' => ['20'], 'title' => ["Foobar2"], 'type' => ["Module_Dog"]}}
|
@@ -32,12 +33,23 @@ module Inquisitio
|
|
32
33
|
assert_equal @found, searcher.total_entries
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
+
def test_should_return_time_taken_for_2011
|
36
37
|
searcher = Searcher.where("star_wars")
|
37
38
|
searcher.search
|
38
39
|
assert_equal 3, searcher.time_ms
|
39
40
|
end
|
40
41
|
|
42
|
+
def test_should_return_time_taken_for_2013
|
43
|
+
Inquisitio.config.api_version = '2013-01-01'
|
44
|
+
body = "{\"status\": {\"rid\" : \"u9aP4eYo8gIK0csK\", \"time-ms\": 4}, \"hits\" : {\"#{@found}\": 33, \"#{@start}\": 0, \"hit\":#{@expected_results.to_json} }}"
|
45
|
+
Excon.stubs.clear
|
46
|
+
Excon.stub({}, {body: body, status: 200})
|
47
|
+
|
48
|
+
searcher = Searcher.where("star_wars")
|
49
|
+
searcher.search
|
50
|
+
assert_equal 4, searcher.time_ms
|
51
|
+
end
|
52
|
+
|
41
53
|
def test_total_entries_should_proxy
|
42
54
|
searcher = Searcher.where("star_wars")
|
43
55
|
searcher.search
|