devStorm
2021-12-04 15:26:30 -05:00
parent dfc44b63b8
commit f61a22500d
7 changed files with 11 additions and 12 deletions
+1 -1
View File
@@ -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(
+1 -2
View File
@@ -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(
+1 -1
View File
@@ -89,9 +89,9 @@ const totalCommitsFetcher = async (username) => {
async function fetchStats(
username,
ownerAffiliations,
count_private = false,
include_all_commits = false,
ownerAffiliations,
) {
if (!username) throw Error("Invalid username");
+1 -1
View File
@@ -34,7 +34,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
+4 -4
View File
@@ -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,
+2 -2
View File
@@ -59,7 +59,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",
@@ -77,7 +77,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'.",
);
});
+1 -1
View File
@@ -2,7 +2,7 @@
"functions": {
"api/*.js": {
"memory": 128,
"maxDuration": 30
"maxDuration": 10
}
},
"redirects": [