From 0e0b5dfd7a83d8356ce574e26e10f3154c485c9f Mon Sep 17 00:00:00 2001 From: devStorm <59678453+developStorm@users.noreply.github.com> Date: Sat, 4 Dec 2021 15:26:30 -0500 Subject: [PATCH] Apply patches https://github.com/anuraghazra/github-readme-stats/pull/1122#issuecomment-986085496 --- api/index.js | 2 +- api/top-langs.js | 3 +-- src/fetchers/stats-fetcher.js | 2 +- tests/fetchStats.test.js | 8 ++++---- tests/fetchTopLanguages.test.js | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/api/index.js b/api/index.js index 9ec08f6561841..8d50f60009832 100644 --- a/api/index.js +++ b/api/index.js @@ -48,9 +48,9 @@ module.exports = async (req, res) => { try { const stats = await fetchStats( username, + parseArray(role), parseBoolean(count_private), parseBoolean(include_all_commits), - parseArray(role), ); const cacheSeconds = clampValue( diff --git a/api/top-langs.js b/api/top-langs.js index f33df8662f9ea..068745d9b1a50 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -45,9 +45,8 @@ module.exports = async (req, res) => { try { const topLangs = await fetchTopLanguages( username, - parseArray(exclude_repo), parseArray(role), - parseArray(hide), + parseArray(exclude_repo), ); const cacheSeconds = clampValue( diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 6cfdcf5f14234..f783d2e10a3c7 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -105,9 +105,9 @@ const totalCommitsFetcher = async (username) => { */ async function fetchStats( username, + ownerAffiliations, count_private = false, include_all_commits = false, - ownerAffiliations, ) { if (!username) throw new MissingParamError(["username"]); diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index f732182f8fe5a..f6a332eab5591 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -52,7 +52,7 @@ describe("Test fetchStats", () => { it("should fetch correct stats", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data); - let stats = await fetchStats("anuraghazra"); + let stats = await fetchStats("anuraghazra", []); const rank = calculateRank({ totalCommits: 100, totalRepos: 5, @@ -77,7 +77,7 @@ describe("Test fetchStats", () => { it("should throw error", async () => { mock.onPost("https://api.github.com/graphql").reply(200, error); - await expect(fetchStats("anuraghazra")).rejects.toThrow( + await expect(fetchStats("anuraghazra", [])).rejects.toThrow( "Could not resolve to a User with the login of 'noname'.", ); }); @@ -85,7 +85,7 @@ describe("Test fetchStats", () => { it("should fetch and add private contributions", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data); - let stats = await fetchStats("anuraghazra", true); + let stats = await fetchStats("anuraghazra", [], true); const rank = calculateRank({ totalCommits: 150, totalRepos: 5, @@ -113,7 +113,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, true); + let stats = await fetchStats("anuraghazra", [], true, true); const rank = calculateRank({ totalCommits: 1050, totalRepos: 5, diff --git a/tests/fetchTopLanguages.test.js b/tests/fetchTopLanguages.test.js index 54238df179e25..76afe89419caf 100644 --- a/tests/fetchTopLanguages.test.js +++ b/tests/fetchTopLanguages.test.js @@ -63,7 +63,7 @@ describe("FetchTopLanguages", () => { it("should fetch correct language data", async () => { mock.onPost("https://api.github.com/graphql").reply(200, data_langs); - let repo = await fetchTopLanguages("anuraghazra"); + let repo = await fetchTopLanguages("anuraghazra", []); expect(repo).toStrictEqual({ HTML: { color: "#0f0", @@ -99,7 +99,7 @@ describe("FetchTopLanguages", () => { it("should throw error", async () => { mock.onPost("https://api.github.com/graphql").reply(200, error); - await expect(fetchTopLanguages("anuraghazra")).rejects.toThrow( + await expect(fetchTopLanguages("anuraghazra", [])).rejects.toThrow( "Could not resolve to a User with the login of 'noname'.", ); });