Commit 12b031ce authored by Stan Hu's avatar Stan Hu

Fix pagination

parent 022a0c2f
...@@ -16,7 +16,7 @@ module BitbucketServer ...@@ -16,7 +16,7 @@ module BitbucketServer
def get(path, extra_query = {}) def get(path, extra_query = {})
response = Gitlab::HTTP.get(build_url(path), response = Gitlab::HTTP.get(build_url(path),
basic_auth: auth, basic_auth: auth,
params: extra_query) query: extra_query)
check_errors!(response) check_errors!(response)
response.parsed_response response.parsed_response
......
module BitbucketServer module BitbucketServer
class Paginator class Paginator
PAGE_LENGTH = 25 # The minimum length is 10 and the maximum is 100. PAGE_LENGTH = 25
def initialize(connection, url, type) def initialize(connection, url, type)
@connection = connection @connection = connection
...@@ -24,12 +24,12 @@ module BitbucketServer ...@@ -24,12 +24,12 @@ module BitbucketServer
page.nil? || page.next? page.nil? || page.next?
end end
def next_url def next_offset
page.nil? ? url : page.next page.nil? ? 0 : page.next
end end
def fetch_next_page def fetch_next_page
parsed_response = connection.get(next_url, pagelen: PAGE_LENGTH, sort: :created_on) parsed_response = connection.get(@url, start: next_offset, limit: PAGE_LENGTH)
Page.new(parsed_response, type) Page.new(parsed_response, type)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment