Unverified Commit 3c6c142c authored by Anurag Hazra's avatar Anurag Hazra Committed by GitHub
Browse files

fix: wrong total commits (#490)

parent 278d6a17
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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;

+2 −2
Original line number Diff line number Diff line
@@ -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,