diff options
author | Stan Hu <stanhu@gmail.com> | 2019-01-07 08:09:41 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-01-07 08:13:00 +0300 |
commit | a06b7a7d5d6012b3f89ddaab5189a85f5cc49c14 (patch) | |
tree | c49fd3f45ea5b7fafc7ad14312e41658edb453db /lib/bitbucket_server | |
parent | d432d674148601555c4ba693bb7c282ac9fe3d4a (diff) |
Fix Bitbucket Server import only including first 25 pull requests
The change to paginate repos in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22825 caused the
paginator to stop after 25 pull requests because the limit was set to 25
if none was defined. To fix this, we should only stop if the limit has
actually been set and use the limit parameter to determine the maximum
number of items to process per page.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55914
Diffstat (limited to 'lib/bitbucket_server')
-rw-r--r-- | lib/bitbucket_server/paginator.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/bitbucket_server/paginator.rb b/lib/bitbucket_server/paginator.rb index aa5f84f44b3..9eda1c921b2 100644 --- a/lib/bitbucket_server/paginator.rb +++ b/lib/bitbucket_server/paginator.rb @@ -12,7 +12,7 @@ module BitbucketServer @url = url @page = nil @page_offset = page_offset - @limit = limit || PAGE_LENGTH + @limit = limit @total = 0 end @@ -34,6 +34,8 @@ module BitbucketServer attr_reader :connection, :page, :url, :type, :limit def over_limit? + return false unless @limit + @limit.positive? && @total >= @limit end @@ -42,11 +44,15 @@ module BitbucketServer end def starting_offset - [0, page_offset - 1].max * limit + [0, page_offset - 1].max * max_per_page + end + + def max_per_page + limit || PAGE_LENGTH end def fetch_next_page - parsed_response = connection.get(@url, start: next_offset, limit: @limit) + parsed_response = connection.get(@url, start: next_offset, limit: max_per_page) Page.new(parsed_response, type) end end |