How can I find how many of my GitHub pull requests have been accepted?
git, github, github-api, pull-request
Solution
You can also use GraphQL API v4 to use a single request to get total number of issues, PR with count per state (`CLOSED`, `OPENED` or `MERGED`) :
{
user(login: "bertrandmartel") {
totalPR: pullRequests {
totalCount
}
openedPR: pullRequests(states: OPEN) {
totalCount
}
closedPR: pullRequests(states: CLOSED) {
totalCount
}
mergedPR: pullRequests(states: MERGED) {
totalCount
}
totalIssues: issues {
totalCount
}
openedIssues: issues(states: OPEN) {
totalCount
}
closedIssues: issues(states: CLOSED) {
totalCount
}
}
}
Try it in the explorer
which gives you a result like the following :
{
"data": {
"user": {
"totalPR": {
"totalCount": 17
},
"openedPR": {
"totalCount": 4
},
"closedPR": {
"totalCount": 1
},
"mergedPR": {
"totalCount": 12
},
"totalIssues": {
"totalCount": 80
},
"openedIssues": {
"totalCount": 7
},
"closedIssues": {
"totalCount": 73
}
}
}
}
Problem
Is there a way to find out the acceptance rate of one's GitHub PR's, probably using the API? While at that, it would be interesting to find out how many of the issues I reported have been closed vs. are still open, across all repos.