diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index d1cc06d..761b7f1 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -115,16 +115,21 @@ async function fetchStats( stats.name = user.name || user.login; stats.totalIssues = user.issues.totalCount; + // normal commits stats.totalCommits = user.contributionsCollection.totalCommitContributions; - if (count_private) { - stats.totalCommits += user.contributionsCollection.restrictedContributionsCount; - } - + // if include_all_commits then just get that, + // since totalCommitsFetcher already sends totalCommits no need to += if (include_all_commits) { stats.totalCommits = await totalCommitsFetcher(username); } + // if count_private then add private commits to totalCommits so far. + if (count_private) { + stats.totalCommits += + user.contributionsCollection.restrictedContributionsCount; + } + stats.totalPRs = user.pullRequests.totalCount; stats.contributedTo = user.repositoriesContributedTo.totalCount; diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index 558b882..077c217 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -114,7 +114,7 @@ describe("Test fetchStats", () => { let stats = await fetchStats("anuraghazra", true, true); const rank = calculateRank({ - totalCommits: 1000, + totalCommits: 1050, totalRepos: 5, followers: 100, contributions: 61, @@ -126,7 +126,7 @@ describe("Test fetchStats", () => { expect(stats).toStrictEqual({ contributedTo: 61, name: "Anurag Hazra", - totalCommits: 1000, + totalCommits: 1050, totalIssues: 200, totalPRs: 300, totalStars: 400,