Skip to content

Commit 7d9832f

Browse files
developStormkvdomingo
authored andcommitted
1 parent 223cb9d commit 7d9832f

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

api/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ export default async (req, res) => {
5151
try {
5252
const stats = await fetchStats(
5353
username,
54+
parseArray(role),
5455
parseBoolean(count_private),
5556
parseBoolean(include_all_commits),
56-
parseArray(role),
5757
);
5858

5959
const cacheSeconds = clampValue(

api/top-langs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ export default async (req, res) => {
4444
try {
4545
const topLangs = await fetchTopLanguages(
4646
username,
47-
parseArray(exclude_repo),
4847
parseArray(role),
49-
parseArray(hide),
48+
parseArray(exclude_repo),
5049
);
5150

5251
const cacheSeconds = clampValue(

src/fetchers/stats-fetcher.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ const totalCommitsFetcher = async (username) => {
213213
*/
214214
const fetchStats = async (
215215
username,
216+
ownerAffiliations,
216217
count_private = false,
217218
include_all_commits = false,
218-
ownerAffiliations,
219219
) {
220220
if (!username) throw Error("Invalid username");
221221

src/fetchers/top-languages-fetcher.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const fetcher = (variables, token) => {
4747
);
4848
};
4949

50-
async function fetchTopLanguages(username, exclude_repo = [], ownerAffiliations) {
50+
async function fetchTopLanguages(username, ownerAffiliations, exclude_repo = []) {
5151
if (!username) throw Error("Invalid username");
5252

5353
// Set default value for ownerAffiliations in GraphQL query won't work because

tests/fetchStats.test.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ describe("Test fetchStats", () => {
240240
it("should fetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set to `true`", async () => {
241241
process.env.FETCH_MULTI_PAGE_STARS = true;
242242

243-
let stats = await fetchStats("anuraghazra");
243+
let stats = await fetchStats("anuraghazra", []);
244244
const rank = calculateRank({
245245
totalCommits: 100,
246246
totalRepos: 5,
@@ -265,7 +265,15 @@ describe("Test fetchStats", () => {
265265
it("should fetch one page of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set to `false`", async () => {
266266
process.env.FETCH_MULTI_PAGE_STARS = "false";
267267

268-
let stats = await fetchStats("anuraghazra");
268+
await expect(fetchStats("anuraghazra", [])).rejects.toThrow(
269+
"Could not resolve to a User with the login of 'noname'.",
270+
);
271+
});
272+
273+
it("should fetch and add private contributions", async () => {
274+
mock.onPost("https://api.github.com/graphql").reply(200, data);
275+
276+
let stats = await fetchStats("anuraghazra", [], true);
269277
const rank = calculateRank({
270278
totalCommits: 100,
271279
totalRepos: 5,
@@ -290,7 +298,7 @@ describe("Test fetchStats", () => {
290298
it("should fetch one page of stars if 'FETCH_MULTI_PAGE_STARS' env variable is not set", async () => {
291299
process.env.FETCH_MULTI_PAGE_STARS = undefined;
292300

293-
let stats = await fetchStats("anuraghazra");
301+
let stats = await fetchStats("anuraghazra", [], true, true);
294302
const rank = calculateRank({
295303
totalCommits: 100,
296304
totalRepos: 5,

tests/fetchTopLanguages.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("FetchTopLanguages", () => {
6363
it("should fetch correct language data", async () => {
6464
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
6565

66-
let repo = await fetchTopLanguages("anuraghazra");
66+
let repo = await fetchTopLanguages("anuraghazra", []);
6767
expect(repo).toStrictEqual({
6868
HTML: {
6969
color: "#0f0",
@@ -99,7 +99,7 @@ describe("FetchTopLanguages", () => {
9999
it("should throw error", async () => {
100100
mock.onPost("https://api.github.com/graphql").reply(200, error);
101101

102-
await expect(fetchTopLanguages("anuraghazra")).rejects.toThrow(
102+
await expect(fetchTopLanguages("anuraghazra", [])).rejects.toThrow(
103103
"Could not resolve to a User with the login of 'noname'.",
104104
);
105105
});

0 commit comments

Comments
 (0)