List all PRs awaiting review from a user #1794
-
Hi, I've been looking into this and I'm not sure if it's possible. For example, let's assume there are
Pull requests M, Q, and W, are awaiting a review from a given user. I want to get that list with M, Q, W. I haven't found anything dedicated neither in Octokit docs nor in GH API docs. The closest I can find is https://docs.github.com/en/rest/reference/pulls#list-requested-reviewers-for-a-pull-request that translates to https://octokit.github.io/rest.js/v18#pulls-list-requested-reviewers If this was limited to a single known repo with a couple of open PRs, I could walk through each open PR matching the list of requested reviewers to the authorized user. It wouldn't be pretty although it would do the job. Now, I don't know the repos or their number, and it could end up being quite large. So I wonder if there's some way I'm missing to get this info in a proper way. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
What I would recommend to do is to use the search API. It supports the same options as the search on github.com, e.g. here are all the open pull requests that request a review by the authenticated user: https://github.com/pulls?q=is%3Aopen+is%3Apr+review-requested%3A%40me+ The code with octokit.search.issuesAndPullRequests({
q: 'is:open is:pr review-requested:@me'
}) To paginate all results, you can do const results = octokit.paginate(search.issuesAndPullRequests, {
q: 'is:open is:pr review-requested:@me'
}) Note that search API requests are much more rate-limited than other API requests. If you hit rate/abuse limits, consider using https://github.com/octokit/plugin-throttling.js/ Hope that helps? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! That looks promising. |
Beta Was this translation helpful? Give feedback.
What I would recommend to do is to use the search API. It supports the same options as the search on github.com, e.g. here are all the open pull requests that request a review by the authenticated user: https://github.com/pulls?q=is%3Aopen+is%3Apr+review-requested%3A%40me+
The code with
@octokit/rest
for that query would beTo paginate all results, you can do
Note that search API requests are much more rate-limited than other API requests. If you hit rate/abuse limits, consider using https://github…