Skip to content

Commit

Permalink
Apply patches
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm authored and kvdomingo committed Mar 25, 2023
1 parent 223cb9d commit 7d9832f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export default async (req, res) => {
try {
const stats = await fetchStats(
username,
parseArray(role),
parseBoolean(count_private),
parseBoolean(include_all_commits),
parseArray(role),
);

const cacheSeconds = clampValue(
Expand Down
3 changes: 1 addition & 2 deletions api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ export default async (req, res) => {
try {
const topLangs = await fetchTopLanguages(
username,
parseArray(exclude_repo),
parseArray(role),
parseArray(hide),
parseArray(exclude_repo),
);

const cacheSeconds = clampValue(
Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ const totalCommitsFetcher = async (username) => {
*/
const fetchStats = async (
username,
ownerAffiliations,
count_private = false,
include_all_commits = false,
ownerAffiliations,
) {
if (!username) throw Error("Invalid username");

Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/top-languages-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const fetcher = (variables, token) => {
);
};

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

// Set default value for ownerAffiliations in GraphQL query won't work because
Expand Down
14 changes: 11 additions & 3 deletions tests/fetchStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe("Test fetchStats", () => {
it("should fetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set to `true`", async () => {
process.env.FETCH_MULTI_PAGE_STARS = true;

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

let stats = await fetchStats("anuraghazra");
await expect(fetchStats("anuraghazra", [])).rejects.toThrow(
"Could not resolve to a User with the login of 'noname'.",
);
});

it("should fetch and add private contributions", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data);

let stats = await fetchStats("anuraghazra", [], true);
const rank = calculateRank({
totalCommits: 100,
totalRepos: 5,
Expand All @@ -290,7 +298,7 @@ describe("Test fetchStats", () => {
it("should fetch one page of stars if 'FETCH_MULTI_PAGE_STARS' env variable is not set", async () => {
process.env.FETCH_MULTI_PAGE_STARS = undefined;

let stats = await fetchStats("anuraghazra");
let stats = await fetchStats("anuraghazra", [], true, true);
const rank = calculateRank({
totalCommits: 100,
totalRepos: 5,
Expand Down
4 changes: 2 additions & 2 deletions tests/fetchTopLanguages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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'.",
);
});
Expand Down

0 comments on commit 7d9832f

Please sign in to comment.