Skip to content

Commit

Permalink
Add default affiliation
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm authored and rickstaa committed Mar 22, 2022
1 parent 3b68abe commit 81ff6d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ async function fetchStats(
rank: { level: "C", score: 0 },
};

let res = await retryer(fetcher, { login: username, ownerAffiliations});
// Set default value for ownerAffiliations in GraphQL query won't work because
// parseArray() will always return an empty array even nothing was specified
// and GraphQL would consider that empty arr as a valid value. Nothing will be
// queried in that case as no affiliation is presented.
ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"];
let res = await retryer(fetcher, { login: username, ownerAffiliations });

if (res.data.errors) {
logger.error(res.data.errors);
Expand Down
5 changes: 5 additions & 0 deletions src/fetchers/top-languages-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const fetcher = (variables, token) => {
async function fetchTopLanguages(username, ownerAffiliations, exclude_repo = []) {
if (!username) throw new MissingParamError(["username"]);

// Set default value for ownerAffiliations in GraphQL query won't work because
// parseArray() will always return an empty array even nothing was specified
// and GraphQL would consider that empty arr as a valid value. Nothing will be
// queried in that case as no affiliation is presented.
ownerAffiliations = ownerAffiliations.length > 0 ? ownerAffiliations : ["OWNER"];
const res = await retryer(fetcher, { login: username, ownerAffiliations });

if (res.data.errors) {
Expand Down

0 comments on commit 81ff6d6

Please sign in to comment.