I’m currently building a service that retrieves my GitHub profile’s relevant metrics. I’ve successfully managed to get stargazer, watcher and fork count across all my repositories, but I’m struggling to do it for both pull request and commit count.
I am using octokit/[email protected]
‘s paginate method to handle pagination.
When retrieving the pull request count:
private async _getPullRequestsCount() {
const pullRequests = await this._octokit.paginate(
this._octokit.search.issuesAndPullRequests,
{
q: `author:${this._username} type:pr`,
per_page: 100,
}
);
return pullRequests.length;
}
it returns 155.
When fetching the number of commits:
private async _getCommitsCount() {
const commits = await this._octokit.paginate(this._octokit.search.commits, {
q: `author:${this._username}`,
per_page: 100,
});
return commits.length;
}
it returns 758.
However when using the GitHub website’s search function, I get different results, of 351 PRs and 2k commits:
I’m also using both the throttling and retry plugins for octokit to make sure it’s not unexpectedly hitting any rate limits.