The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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
TAGS
AUG Leaders

Atlassian Community Events