mirror of
https://github.com/Aviortheking/codestats-readme.git
synced 2025-07-28 14:59:53 +00:00
feat: Add count_private flag to count private contributions (#148)
* Add private contributions count * Remove unused var and add tests * Update readme * fix: tests & minor code formating * docs: updated docs Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
This commit is contained in:
@ -13,6 +13,7 @@ const fetcher = (variables, token) => {
|
||||
login
|
||||
contributionsCollection {
|
||||
totalCommitContributions
|
||||
restrictedContributionsCount
|
||||
}
|
||||
repositoriesContributedTo(first: 1, contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]) {
|
||||
totalCount
|
||||
@ -45,7 +46,7 @@ const fetcher = (variables, token) => {
|
||||
);
|
||||
};
|
||||
|
||||
async function fetchStats(username) {
|
||||
async function fetchStats(username, count_private = false) {
|
||||
if (!username) throw Error("Invalid username");
|
||||
|
||||
const stats = {
|
||||
@ -66,10 +67,18 @@ async function fetchStats(username) {
|
||||
}
|
||||
|
||||
const user = res.data.data.user;
|
||||
const contributionCount = user.contributionsCollection;
|
||||
|
||||
stats.name = user.name || user.login;
|
||||
stats.totalIssues = user.issues.totalCount;
|
||||
stats.totalCommits = user.contributionsCollection.totalCommitContributions;
|
||||
|
||||
stats.totalCommits = contributionCount.totalCommitContributions;
|
||||
if (count_private) {
|
||||
stats.totalCommits =
|
||||
contributionCount.totalCommitContributions +
|
||||
contributionCount.restrictedContributionsCount;
|
||||
}
|
||||
|
||||
stats.totalPRs = user.pullRequests.totalCount;
|
||||
stats.contributedTo = user.repositoriesContributedTo.totalCount;
|
||||
|
||||
|
Reference in New Issue
Block a user