inquisitio 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/inquisitio/search_url_builder.rb +5 -10
- data/lib/inquisitio/searcher.rb +3 -4
- data/lib/inquisitio/version.rb +1 -1
- data/test/test_searcher.rb +6 -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: ec481031a9aa085e8b4a41f8cfa054415645f7e1
|
4
|
+
data.tar.gz: 3c52019c27f4b86f38a2da70dd063ec58b2be998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 289d6a4cf32a0a112648c82e9ad38f755eac8a30dc8e13f804d3a01af58f63543843c73f1d2fb4c45645e5a5808fc43ab67fcef426edc5047db8d783f6bb52cd
|
7
|
+
data.tar.gz: ce0514c3be78138eb48447b5cf098025d437bb4831dfe408df120e3cb6a5b86d2a2437dae078cb5b6c2e10ef3b7a99d672ccb9f85fcaebed8441b4fbc2ac1101
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
data/lib/inquisitio/searcher.rb
CHANGED
@@ -152,10 +152,9 @@ module Inquisitio
|
|
152
152
|
SearchUrlBuilder.build(
|
153
153
|
query: params[:criteria],
|
154
154
|
filters: params[:filters],
|
155
|
-
arguments: params[:with]
|
156
|
-
|
157
|
-
|
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
|
data/lib/inquisitio/version.rb
CHANGED
data/test/test_searcher.rb
CHANGED
@@ -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?
|
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
|