Pull requests opened" is always 0 although viewer.pullRequests.totalCount returns 21 #1836
Replies: 3 comments
|
The discrepancy is expected. GitHub's GraphQL has two different PR counters: viewer.pullRequests.totalCount = ALL pull requests you've ever authored (on any repo, including your own). contributionsCollection.totalPullRequestContributions = pull requests that count as contributions — which excludes PRs on repos you own. Metrics uses contributionsCollection, so PRs on your own repos (or forks of them) are excluded. If your 21 PRs are on repos you own, they'll show as 0 here. To verify, try the query filtering by repos you don't own: If you want all PRs counted, you'd need Metrics to switch from contributionsCollection to viewer.pullRequests — that's a feature request you could open as an issue. If this answered your question, marking it as accepted would help others with the same issue! |
|
Thanks! I ran the additional query and I think my case is different. My pull requests are not on repositories I own. For all of them:
However, GitHub still returns: {
viewer {
contributionsCollection {
pullRequestContributions(first: 20) {
totalCount
}
}
}
}Response: {
"data": {
"viewer": {
"contributionsCollection": {
"pullRequestContributions": {
"totalCount": 0,
"nodes": []
}
}
}
}
}while {
viewer {
pullRequests(first: 50) {
totalCount
}
}
}returns: {
"totalCount": 22
}So it looks like GitHub itself is not exposing any of my pull requests through Have you seen this behavior before? |
GraphQL only returns data for the last year by default. Requesting contributionsCollection {
totalPullRequestContributions
}returns But requesting contributionsCollection (from: "2022-01-01T00:00:00Z") {
totalPullRequestContributions
}returns As documented here:
|

Uh oh!
There was an error while loading. Please reload this page.
Hi!
I think I found an inconsistency between the metric displayed by Metrics and the GitHub GraphQL API.
Environment
repo,read:user,read:orgWorkflow:
What I see
My GitHub profile correctly shows the pull requests I opened in private repositories.
The following GraphQL query also returns all of my pull requests:
{ viewer { pullRequests(first: 10) { totalCount } } }Result:
{ "data": { "viewer": { "pullRequests": { "totalCount": 21 } } } }However, Metrics always displays:
Running this query:
{ viewer { contributionsCollection { totalPullRequestContributions restrictedContributionsCount } } }returns:
{ "data": { "viewer": { "contributionsCollection": { "restrictedContributionsCount": 185, "totalPullRequestContributions": 0 } } } }Question
Is this expected?
Does Metrics intentionally use
contributionsCollection.totalPullRequestContributionsinstead ofviewer.pullRequests.totalCount?From a user's perspective, the label "Pull requests opened" suggests the latter, while the current implementation appears to display contribution-counted pull requests instead.
Thanks!
All reactions