Is it possible to get the number of open pull requests older than particular time using API?

Alfred March 30, 2020

Hi folks,

I know how to get the number of open pull requests in either Bitbucket Cloud or Bitbucket Server, using GET API. I would like to know if it is possible to get the number of open pull requests beyond a particular time. For example, the number of open pull requests older than today, or older than 24 hr,etc. Is this possible?

Thank you.

1 answer

1 accepted

0 votes
Answer accepted
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 30, 2020

Hello @Alfred ,

In Bitbucket Cloud the query would be something like this:

created_on < "2019-01-01T00:00:00.00" AND state="OPEN"

For example, all open pull requests created before 2019:

https://bitbucket.org/!api/2.0/repositories/atlassian/atlaskit-mk-2/pullrequests?q=created_on%20%3C%20%222019-01-01T00%3A00%3A00.00%22%20AND%20state%3D%22OPEN%22

To just count such PRs you can filter the response down to only size property:

https://bitbucket.org/!api/2.0/repositories/atlassian/atlaskit-mk-2/pullrequests?q=created_on%20%3C%20%222019-01-01T00%3A00%3A00.00%22%20AND%20state%3D%22OPEN%22&fields=size

As for Bitbucket Server, it looks like there's no way to filter by creation date, unfortunately. You can work around this by doing calculations on the client side since the PRs can be ordered by creation date, both ascending and descending.

Hope this helps.

Cheers,
Daniil

Alfred March 30, 2020

Thanks @Daniil Penkin for your support :)

Regards,

Alfred

Like Daniil Penkin likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events