-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for more than 500 bins #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -86,7 +86,11 @@ def bin(name_or_regex) | |||||||
|
||||||||
def bins | ||||||||
@bins ||= begin | ||||||||
get('/bins?max-results=500').map do |bin_data| | ||||||||
per_page = 500 | ||||||||
data = (0..1).inject([]) do |list, page| | ||||||||
list += get("/bins?max-results=#{per_page}&page-token=#{page * 500}") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, their API is a bit odd… Assuming it works. |
||||||||
end | ||||||||
data.map do |bin_data| | ||||||||
Comment on lines
+92
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I might suggest this and discarding the
Suggested change
|
||||||||
Bin.new(bin_data['_id'], bin_data['name']) | ||||||||
end | ||||||||
end | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -181,11 +181,15 @@ class ClientTest < Minitest::Test | |||||||
client = Vimaly::Client.new('company_id', user_credentials: { username: 'username', password: 'password' }) | ||||||||
bins = client.bins | ||||||||
|
||||||||
assert_equal 2, bins.size | ||||||||
assert_equal 4, bins.size # API called twice now (2 pages) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, so our Mocked API is returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something a bit more? Out-of-context I think it's confusing.
Suggested change
|
||||||||
assert_equal 'Alpha', bins[0].name | ||||||||
assert_equal 1, bins[0].id | ||||||||
assert_equal 'Beta', bins[1].name | ||||||||
assert_equal 2, bins[1].id | ||||||||
assert_equal 'Alpha', bins[2].name | ||||||||
assert_equal 1, bins[2].id | ||||||||
assert_equal 'Beta', bins[3].name | ||||||||
assert_equal 2, bins[3].id | ||||||||
end | ||||||||
end | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this breaks when I add 450 more bins? Sounds good. Can you make it break harder so if we have 1000 bins we're forced to move away…as a failsafe?