diff --git a/api/index.js b/api/index.js index 21448f92..29ff87f9 100644 --- a/api/index.js +++ b/api/index.js @@ -19,6 +19,7 @@ export default async (req, res) => { card_width, hide_rank, show_icons, + count_private, include_all_commits, line_height, title_color, @@ -51,6 +52,7 @@ export default async (req, res) => { try { const stats = await fetchStats( username, + parseBoolean(count_private), parseBoolean(include_all_commits), parseArray(exclude_repo), ); diff --git a/docs/readme_fr.md b/docs/readme_fr.md index 6da4fefd..ba9d8da3 100644 --- a/docs/readme_fr.md +++ b/docs/readme_fr.md @@ -148,6 +148,7 @@ Vous pouvez fournir plusieurs valeurs (suivie d'une virgule) dans l'option bg_co - `hide_rank` - Masquer le rang _(boolean)_ - `show_icons` - Afficher les icônes _(boolean)_ - `include_all_commits` - Compter le total de commits au lieu de ne compter que les commits de l'année en cours _(boolean)_ +- `count_private` - Compter les contributions privées _(boolean)_ - `line_height` - Fixer la hauteur de la ligne entre les textes _(number)_ #### Repo Card Exclusive Options: diff --git a/readme.md b/readme.md index ba3ab527..45fba4a3 100644 --- a/readme.md +++ b/readme.md @@ -270,6 +270,7 @@ You can provide multiple comma-separated values in the bg_color option to render - `rank_icon` - Shows alternative rank icon (i.e. `github` or `default`). Default: `default`. - `show_icons` - _(boolean)_. Default: `false`. - `include_all_commits` - Count total commits instead of just the current year commits _(boolean)_. Default: `false`. +- `count_private` - Count private contributions _(boolean)_. Default: `false`. - `line_height` - Sets the line height between text _(number)_. Default: `25`. - `exclude_repo` - Exclude stars from specified repositories _(Comma-separated values)_. Default: `[] (blank array)`. - `custom_title` - Sets a custom title for the card. Default: ` GitHub Stats`. diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 3d6f9f5e..aff7fcbd 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -173,11 +173,13 @@ const totalCommitsFetcher = async (username) => { * Fetch stats for a given username. * * @param {string} username GitHub username. + * @param {boolean} count_private Include private contributions. * @param {boolean} include_all_commits Include all commits. * @returns {Promise} Stats data. */ const fetchStats = async ( username, + count_private = false, // unused include_all_commits = false, exclude_repo = [], ) => { diff --git a/tests/api.test.js b/tests/api.test.js index cb3e1418..0f82de5e 100644 --- a/tests/api.test.js +++ b/tests/api.test.js @@ -33,6 +33,7 @@ const data_stats = { repositoriesContributedTo: { totalCount: stats.contributedTo }, contributionsCollection: { totalCommitContributions: stats.totalCommits, + restrictedContributionsCount: 100, }, pullRequests: { totalCount: stats.totalPRs }, openIssues: { totalCount: stats.totalIssues }, diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index 4e8f4d80..879173df 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -10,7 +10,10 @@ const data_stats = { user: { name: "Anurag Hazra", repositoriesContributedTo: { totalCount: 61 }, - contributionsCollection: { totalCommitContributions: 100 }, + contributionsCollection: { + totalCommitContributions: 100, + restrictedContributionsCount: 50, + }, pullRequests: { totalCount: 300 }, openIssues: { totalCount: 100 }, closedIssues: { totalCount: 100 }, @@ -162,7 +165,7 @@ describe("Test fetchStats", () => { .onGet("https://api.github.com/search/commits?q=author:anuraghazra") .reply(200, { total_count: 1000 }); - let stats = await fetchStats("anuraghazra", true); + let stats = await fetchStats("anuraghazra", true, true); const rank = calculateRank({ all_commits: true, commits: 1000, @@ -189,7 +192,7 @@ describe("Test fetchStats", () => { .onGet("https://api.github.com/search/commits?q=author:anuraghazra") .reply(200, { total_count: 1000 }); - let stats = await fetchStats("anuraghazra", true, ["test-repo-1"]); + let stats = await fetchStats("anuraghazra", true, true, ["test-repo-1"]); const rank = calculateRank({ all_commits: true, commits: 1000,