-
Notifications
You must be signed in to change notification settings - Fork 0
Support search for more than 200 tickets #22
Conversation
639031c
to
62fca2f
Compare
62fca2f
to
384d309
Compare
The search_tickets function should now get up to 5000 tickets. It does this by making multiple requests with pagination at the maximum amount of 500 per request
384d309
to
0a6ec8a
Compare
lib/vimaly/client.rb
Outdated
Ticket.from_vimaly(search_response, ticket_type_map, bin_map, custom_fields) | ||
end | ||
|
||
break unless search_response # If reponse is nil then we know we've got all the data |
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.
You could use a case statement for this, like this:
response_tickets = case search_response
when Array
...
when Hash
else # or when NilClass
break
end
lib/vimaly/client.rb
Outdated
Ticket.from_vimaly(ticket_data, ticket_type_map, bin_map, custom_fields) | ||
end | ||
elsif search_response.instance_of? Hash # Will be a hash when only 1 ticket is returned. (most likely because max_results is 1) | ||
Ticket.from_vimaly(search_response, ticket_type_map, bin_map, custom_fields) |
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.
You could return [Ticket.from_vimaly(search_response, ticket_type_map, bin_map, custom_fields)]
here, which allows you to not check for unless search_response.instance_of? Hash
below.
lib/vimaly/client.rb
Outdated
break if response_tickets.size < max_results # Can finish search because we've returned all there is. | ||
end | ||
|
||
tickets << response_tickets |
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.
response_tickets
is an Array and tickets
is an Array, right? Then <<
doesn't do what you think it does (adding the content of one to the other), it adds the response_tickets
as one item into tickets
. You can do this instead:
ticket += response_tickets
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.
No further complaints ❤️
Trying to fix up the search_tickets method so I can use it to search for a bunch of trade confirmation tickets to rerun.
It looks like theres about 700 or so tickets that I need to find in the search