inquisitio 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec481031a9aa085e8b4a41f8cfa054415645f7e1
4
- data.tar.gz: 3c52019c27f4b86f38a2da70dd063ec58b2be998
3
+ metadata.gz: 34e8488ee37d4001d57ec5ed0a318b2532d47f2f
4
+ data.tar.gz: 1a20339ae3942c0e5ba5c0828b725b5f8039f6e0
5
5
  SHA512:
6
- metadata.gz: 289d6a4cf32a0a112648c82e9ad38f755eac8a30dc8e13f804d3a01af58f63543843c73f1d2fb4c45645e5a5808fc43ab67fcef426edc5047db8d783f6bb52cd
7
- data.tar.gz: ce0514c3be78138eb48447b5cf098025d437bb4831dfe408df120e3cb6a5b86d2a2437dae078cb5b6c2e10ef3b7a99d672ccb9f85fcaebed8441b4fbc2ac1101
6
+ metadata.gz: 37b7902705751a607286325de49dd77f331e2ce1c7dd4db4115f09ec40553f88c65f66cde534cbec9691982992a7ede7609b1c613761344857e702cadac1a03d
7
+ data.tar.gz: 034fe6edaa9e2cb468765eec84582e4220b4e2d22d0e37ab686e8efc211aad6ad2086f499c29564811a4896714cece5631c1f3b72d65fc58545f1f6faec7a6ee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 1.2.2 / 2014-06-03
2
+ [FEATURE] Return time taken by queries as time_ms on Searcher
3
+
1
4
  1.2.1 / 2014-06-03
2
5
  [BUGFIX] Fixed start of search offset
3
6
 
@@ -15,7 +15,7 @@ module Inquisitio
15
15
  end
16
16
 
17
17
  def index
18
- Inquisitio.config.logger.info "Indexer posting to #{batch_index_url} body: #{body}"
18
+ Inquisitio.config.logger.info "Indexer posting to #{batch_index_url}"
19
19
  if Inquisitio.config.dry_run
20
20
  Inquisitio.config.logger.info "Skipping POST as running in dry-run mode"
21
21
  else
@@ -26,8 +26,7 @@ module Inquisitio
26
26
  private
27
27
 
28
28
  def body
29
- body = @documents.map(&:to_SDF).join(", ")
30
- "[#{body}]"
29
+ @body ||= "[#{@documents.map(&:to_SDF).join(", ")}]"
31
30
  end
32
31
 
33
32
  def batch_index_url
@@ -38,7 +37,7 @@ module Inquisitio
38
37
  response = Excon.post(batch_index_url,
39
38
  :body => body,
40
39
  :headers => {"Content-Type" =>"application/json"})
41
- Inquisitio.config.logger.info "Response - status: #{response.status} body: #{response.body}"
40
+ Inquisitio.config.logger.info "Response - status: #{response.status}"
42
41
  raise InquisitioError.new("Index failed with status code: #{response.status} Message: #{response.body}") unless response.status == 200
43
42
  response.body
44
43
  end
@@ -1,13 +1,11 @@
1
1
  module Inquisitio
2
2
  class Results < Array
3
- def initialize(items, current_page, results_per_page, total_count)
3
+ def initialize(items, current_page, results_per_page, total_count, time_ms)
4
4
  super(items)
5
- @current_page = current_page
6
- @results_per_page = results_per_page
7
- @total_count = total_count
5
+ @current_page, @results_per_page, @total_count, @time_ms = current_page, results_per_page, total_count, time_ms
8
6
  end
9
7
 
10
- attr_reader :total_count, :results_per_page, :current_page
8
+ attr_reader :total_count, :results_per_page, :current_page, :time_ms
11
9
  alias_method :total_entries, :total_count
12
10
  alias_method :limit_value, :results_per_page
13
11
 
@@ -125,10 +125,11 @@ 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
- @results = Results.new(body["hits"]["hit"],
128
+ @results = Results.new(body['hits']['hit'],
129
129
  params[:page],
130
130
  params[:per],
131
- body["hits"]["found"])
131
+ body['hits']['found'],
132
+ body['info']['time-ms'])
132
133
  rescue => e
133
134
  @failed_attempts += 1
134
135
  Inquisitio.config.logger.error("Exception Performing search: #{search_url} #{e}")
@@ -1,3 +1,3 @@
1
1
  module Inquisitio
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
data/test/results_test.rb CHANGED
@@ -32,6 +32,12 @@ module Inquisitio
32
32
  assert_equal @found, searcher.total_entries
33
33
  end
34
34
 
35
+ def test_should_return_time_taken
36
+ searcher = Searcher.where("star_wars")
37
+ searcher.search
38
+ assert_equal 3, searcher.time_ms
39
+ end
40
+
35
41
  def test_total_entries_should_proxy
36
42
  searcher = Searcher.where("star_wars")
37
43
  searcher.search
@@ -88,13 +94,13 @@ module Inquisitio
88
94
  end
89
95
 
90
96
  def test_last_page_before
91
- results = Inquisitio::Results.new([], 1, nil, nil)
97
+ results = Inquisitio::Results.new([], 1, nil, nil, 7)
92
98
  results.expects(total_pages: 2)
93
99
  refute results.last_page?
94
100
  end
95
101
 
96
102
  def test_last_page_equal
97
- results = Inquisitio::Results.new([], 2, nil, nil)
103
+ results = Inquisitio::Results.new([], 2, nil, nil, 7)
98
104
  results.expects(total_pages: 2)
99
105
  assert results.last_page?
100
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inquisitio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-06-03 00:00:00.000000000 Z
13
+ date: 2014-06-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: excon