Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix commits count when include_all_commits is true #391

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ async function fetchStats(

let res = await retryer(fetcher, { login: username });

let experimental_totalCommits = 0;
if (include_all_commits) {
experimental_totalCommits = await totalCommitsFetcher(username);
}

if (res.data.errors) {
logger.error(res.data.errors);
throw new CustomError(
Expand All @@ -116,16 +111,18 @@ async function fetchStats(
}

const user = res.data.data.user;
const contributionCount = user.contributionsCollection;

stats.name = user.name || user.login;
stats.totalIssues = user.issues.totalCount;

stats.totalCommits =
contributionCount.totalCommitContributions + experimental_totalCommits;
stats.totalCommits = user.contributionsCollection.totalCommitContributions;

if (count_private) {
stats.totalCommits += contributionCount.restrictedContributionsCount;
stats.totalCommits += user.contributionsCollection.restrictedContributionsCount;
}

if (include_all_commits) {
stats.totalCommits = await totalCommitsFetcher(username);
}

stats.totalPRs = user.pullRequests.totalCount;
Expand Down
4 changes: 2 additions & 2 deletions tests/fetchStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("Test fetchStats", () => {

let stats = await fetchStats("anuraghazra", true, true);
const rank = calculateRank({
totalCommits: 1000 + 150,
totalCommits: 1000,
totalRepos: 5,
followers: 100,
contributions: 61,
Expand All @@ -126,7 +126,7 @@ describe("Test fetchStats", () => {
expect(stats).toStrictEqual({
contributedTo: 61,
name: "Anurag Hazra",
totalCommits: 1000 + 150,
totalCommits: 1000,
totalIssues: 200,
totalPRs: 300,
totalStars: 400,
Expand Down