mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2024-12-15 06:04:17 +08:00
fix(stats-card): commits count when include_all_commits is true (#391)
This commit is contained in:
parent
723ec0fde6
commit
851bb7b4b8
@ -102,11 +102,6 @@ async function fetchStats(
|
|||||||
|
|
||||||
let res = await retryer(fetcher, { login: username });
|
let res = await retryer(fetcher, { login: username });
|
||||||
|
|
||||||
let experimental_totalCommits = 0;
|
|
||||||
if (include_all_commits) {
|
|
||||||
experimental_totalCommits = await totalCommitsFetcher(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
logger.error(res.data.errors);
|
logger.error(res.data.errors);
|
||||||
throw new CustomError(
|
throw new CustomError(
|
||||||
@ -116,16 +111,18 @@ async function fetchStats(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = res.data.data.user;
|
const user = res.data.data.user;
|
||||||
const contributionCount = user.contributionsCollection;
|
|
||||||
|
|
||||||
stats.name = user.name || user.login;
|
stats.name = user.name || user.login;
|
||||||
stats.totalIssues = user.issues.totalCount;
|
stats.totalIssues = user.issues.totalCount;
|
||||||
|
|
||||||
stats.totalCommits =
|
stats.totalCommits = user.contributionsCollection.totalCommitContributions;
|
||||||
contributionCount.totalCommitContributions + experimental_totalCommits;
|
|
||||||
|
|
||||||
if (count_private) {
|
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;
|
stats.totalPRs = user.pullRequests.totalCount;
|
||||||
|
@ -114,7 +114,7 @@ describe("Test fetchStats", () => {
|
|||||||
|
|
||||||
let stats = await fetchStats("anuraghazra", true, true);
|
let stats = await fetchStats("anuraghazra", true, true);
|
||||||
const rank = calculateRank({
|
const rank = calculateRank({
|
||||||
totalCommits: 1000 + 150,
|
totalCommits: 1000,
|
||||||
totalRepos: 5,
|
totalRepos: 5,
|
||||||
followers: 100,
|
followers: 100,
|
||||||
contributions: 61,
|
contributions: 61,
|
||||||
@ -126,7 +126,7 @@ describe("Test fetchStats", () => {
|
|||||||
expect(stats).toStrictEqual({
|
expect(stats).toStrictEqual({
|
||||||
contributedTo: 61,
|
contributedTo: 61,
|
||||||
name: "Anurag Hazra",
|
name: "Anurag Hazra",
|
||||||
totalCommits: 1000 + 150,
|
totalCommits: 1000,
|
||||||
totalIssues: 200,
|
totalIssues: 200,
|
||||||
totalPRs: 300,
|
totalPRs: 300,
|
||||||
totalStars: 400,
|
totalStars: 400,
|
||||||
|
Loading…
Reference in New Issue
Block a user