Skip to content

Commit

Permalink
fix: add pagination to getPullrequests() in Bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Dec 12, 2019
1 parent 3c78fe3 commit 47e57ad
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ export class BitbucketService implements IVCSService {
repo: string,
options?: ListGetterOptions<{ state?: PullRequestState }>,
): Promise<Paginated<PullRequest>> {
let state;
if (options?.filter?.state) {
state = VCSServicesUtils.getPRState(options.filter.state, VCSService.bitbucket);
}
const stateForUri = qs.stringify({ state: state }, { addQueryPrefix: true, indices: false, arrayFormat: 'repeat' });
let apiUrl = `https://api.bitbucket.org/2.0/repositories/${owner}/${repo}/pullrequests`;
if (stateForUri) {
apiUrl = apiUrl.concat(`${stateForUri}`);
}

const state = VCSServicesUtils.getPRState(options?.filter?.state, VCSService.bitbucket);
const stateForUri = qs.stringify({ state: state }, { addQueryPrefix: true, indices: false, arrayFormat: 'repeat' });

const paginationForUri = qs.stringify(
{ page: options?.pagination?.page, pagelen: options?.pagination?.perPage },
{ addQueryPrefix: true, indices: false },
);

apiUrl = apiUrl.concat(`${stateForUri}${paginationForUri}`);

const ownerUrl = `www.bitbucket.org/${owner}`;
const ownerId = `${(await this.client.repositories.get({ repo_slug: repo, username: owner })).data.owner?.uuid}`;
Expand Down

0 comments on commit 47e57ad

Please sign in to comment.