inquisitio 1.2.0 → 1.2.1

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: 89aae9dc681251070a23032fd2dab54af311e0cc
4
- data.tar.gz: 3bdf5147f6bd81d43164e38c700255263c58f981
3
+ metadata.gz: ec481031a9aa085e8b4a41f8cfa054415645f7e1
4
+ data.tar.gz: 3c52019c27f4b86f38a2da70dd063ec58b2be998
5
5
  SHA512:
6
- metadata.gz: 0f6218f321736cfa15f6bebd2dc5456817ae118f3e8335929f1c73ab0bf9f0498d5b75db95f5ffe52cbb31a2fd4fd9fed24294995b062798bad30f49fe3aee9b
7
- data.tar.gz: 508afe8065da867c2d0eee4fadbdba18f66aabfc584f9998487f0b516ede922b4a21770eac2eefc7e63fc0d5725133d2b01ebcb3e65bcbd478e2cfc472030419
6
+ metadata.gz: 289d6a4cf32a0a112648c82e9ad38f755eac8a30dc8e13f804d3a01af58f63543843c73f1d2fb4c45645e5a5808fc43ab67fcef426edc5047db8d783f6bb52cd
7
+ data.tar.gz: ce0514c3be78138eb48447b5cf098025d437bb4831dfe408df120e3cb6a5b86d2a2437dae078cb5b6c2e10ef3b7a99d672ccb9f85fcaebed8441b4fbc2ac1101
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 1.2.1 / 2014-06-03
2
+ [BUGFIX] Fixed start of search offset
3
+
1
4
  1.2.0 / 2014-06-03
2
5
  [FEATURE] Support for 2013-01-01 version of cloudsearch API
3
6
 
@@ -8,9 +8,10 @@ module Inquisitio
8
8
  def initialize(options = {})
9
9
  @query = options[:query]
10
10
  @filters = options[:filters] || {}
11
- @arguments = options[:arguments]
11
+ @arguments = options[:arguments] || {}
12
12
  @return_fields = options[:return_fields]
13
- add_default_size if @arguments.nil? || @arguments[:size].nil?
13
+ @size = options[:size] || Inquisitio.config.default_search_size
14
+ @start = options[:start] || 0
14
15
  end
15
16
 
16
17
  def build
@@ -19,6 +20,8 @@ module Inquisitio
19
20
  components << (is_simple ? simple_query : boolean_query)
20
21
  components << return_fields_query_string
21
22
  components << arguments
23
+ components << "&size=#{@size}" unless @arguments[:size]
24
+ components << "&start=#{@start}" unless @arguments[:start] || @start == 0 || @start == '0'
22
25
  components.join("")
23
26
  end
24
27
 
@@ -78,13 +81,5 @@ module Inquisitio
78
81
  "#{Inquisitio.config.search_endpoint}/#{Inquisitio.config.api_version}/search?"
79
82
  end
80
83
 
81
- def add_default_size
82
- if @arguments.nil?
83
- @arguments = {}
84
- end
85
- if @arguments[:size].nil?
86
- @arguments = @arguments.merge(:size => Inquisitio.config.default_search_size)
87
- end
88
- end
89
84
  end
90
85
  end
@@ -152,10 +152,9 @@ module Inquisitio
152
152
  SearchUrlBuilder.build(
153
153
  query: params[:criteria],
154
154
  filters: params[:filters],
155
- arguments: params[:with].merge({
156
- size: params[:per],
157
- start: params[:per] * params[:page]
158
- }),
155
+ arguments: params[:with],
156
+ size: params[:per],
157
+ start: params[:per] * (params[:page] - 1),
159
158
  return_fields: return_fields
160
159
  )
161
160
  end
@@ -1,3 +1,3 @@
1
1
  module Inquisitio
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -168,7 +168,12 @@ module Inquisitio
168
168
 
169
169
  def test_page_gets_correct_url
170
170
  searcher = Searcher.page(3).per(15)
171
- assert searcher.send(:search_url).include? "&start=45"
171
+ assert searcher.send(:search_url).include? '&start=30'
172
+ end
173
+
174
+ def test_that_starts_at_zero
175
+ searcher = Searcher.where("foo")
176
+ refute searcher.send(:search_url).include? '&start='
172
177
  end
173
178
 
174
179
  def test_returns_doesnt_mutate_searcher
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.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker