go-bitbucket icon indicating copy to clipboard operation
go-bitbucket copied to clipboard

Support For Limiting Auto-Pagination Depth

Open tyler-domitrovich opened this issue 3 years ago • 5 comments

It would be nice to be able to limit how many pages of results are returned. Consider the case where we want to retrieve the most recent 20 commits for the main branch of a very active repository. Currently, the auto-pagination will recurse through all pages of results which is time consuming and unnecessary since we would have all of the results we require for this example after the first couple of pages.

tyler-domitrovich avatar Jul 16 '21 04:07 tyler-domitrovich

FYI I was able to get a rough pass of this behavior working in my fork here:

https://github.com/tyler-domitrovich/go-bitbucket/tree/adjustable-pagination-depth

If you have any interest in this feature let me know and I will create a PR!

tyler-domitrovich avatar Jul 16 '21 05:07 tyler-domitrovich

Umm.. DEFAULT_PAGE_LENGTH is not enough?

https://github.com/ktrysmt/go-bitbucket/blob/master/client.go#L24

ktrysmt avatar Jul 19 '21 08:07 ktrysmt

I don't believe so. It looks like DEFAULT_PAGE_LENGTH is used to set pagelen, which does allow us to change the number of results returned per page, but does not allow us to change the number of pages returned so we still will recurse through every page of results available.

tyler-domitrovich avatar Jul 19 '21 17:07 tyler-domitrovich

Certainly. If you have a large number of pages, it may be important to limit the number of pages. By the way, POC smells a little buggy. I think we can make the changes a little smaller.

ktrysmt avatar Jul 20 '21 13:07 ktrysmt

Certainly. If you have a large number of pages, it may be important to limit the number of pages. By the way, POC smells a little buggy. I think we can make the changes a little smaller.

Hello!

Maybe we can be use my PR for this issue?

it small and won't break the old code

https://github.com/ktrysmt/go-bitbucket/pull/199

Zermond avatar May 12 '22 11:05 Zermond