summaryrefslogtreecommitdiff
path: root/lib/chef/search/query.rb
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-12-19 12:28:52 -0800
committerClaire McQuin <claire@getchef.com>2014-12-19 12:28:52 -0800
commitfe8ca9ea64205288d3cc0fa2ea6b80c953f8ea4c (patch)
treeb7dca649ede4f764b75affd68f65c24e6ca97a56 /lib/chef/search/query.rb
parent2ec9334502cff103bc4cef3daf8d213bee211841 (diff)
downloadchef-fe8ca9ea64205288d3cc0fa2ea6b80c953f8ea4c.tar.gz
Remaining fixes.
* Exclude rows from query if rows are nil. * Update defaults in knife/search to match query defaults. * Update start when polling more rows.
Diffstat (limited to 'lib/chef/search/query.rb')
-rw-r--r--lib/chef/search/query.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index 7ca122c986..b68749f196 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -88,8 +88,8 @@ WARNDEP
if block
response["rows"].each { |row| block.call(row) if row }
- if response["start"] + response["rows"].size < response["total"]
- start = response["start"] + rows
+ unless (response["start"] + response["rows"].length) >= response["total"]
+ args_h[:start] = response["start"] + (args_h[:rows] || 0)
search(type, query, args_h, &block)
end
true
@@ -125,7 +125,7 @@ WARNDEP
end
def call_rest_service(type, query:'*:*', rows:nil, start:0, sort:'X_CHEF_id_CHEF_X asc', filter_result:nil)
- query_string = "search/#{type}?q=#{escape(query)}&sort=#{escape(sort)}&start=#{escape(start)}&rows=#{escape(rows)}"
+ query_string = "search/#{type}?q=#{escape(query)}&sort=#{escape(sort)}&start=#{escape(start)}#{"&rows=" + escape(rows) if rows}"
if filter_result
response = rest.post_rest(query_string, filter_result)