Skip to content

Commit

Permalink
Custom ownerAffiliations for general stats
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm committed Jun 10, 2021
1 parent 4edda27 commit 3855938
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = async (req, res) => {
disable_animations,
border_radius,
border_color,
role,
} = req.query;
let stats;

Expand All @@ -51,6 +52,7 @@ module.exports = async (req, res) => {
username,
parseBoolean(count_private),
parseBoolean(include_all_commits),
parseArray(role),
);

const cacheSeconds = clampValue(
Expand Down
7 changes: 4 additions & 3 deletions src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fetcher = (variables, token) => {
return request(
{
query: `
query userInfo($login: String!) {
query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation]) {
user(login: $login) {
name
login
Expand All @@ -31,7 +31,7 @@ const fetcher = (variables, token) => {
followers {
totalCount
}
repositories(first: 100, ownerAffiliations: OWNER, orderBy: {direction: DESC, field: STARGAZERS}) {
repositories(first: 100, ownerAffiliations: $ownerAffiliations, orderBy: {direction: DESC, field: STARGAZERS}) {
totalCount
nodes {
stargazers {
Expand Down Expand Up @@ -88,6 +88,7 @@ async function fetchStats(
username,
count_private = false,
include_all_commits = false,
ownerAffiliations,
) {
if (!username) throw Error("Invalid username");

Expand All @@ -101,7 +102,7 @@ async function fetchStats(
rank: { level: "C", score: 0 },
};

let res = await retryer(fetcher, { login: username });
let res = await retryer(fetcher, { login: username, ownerAffiliations});

if (res.data.errors) {
logger.error(res.data.errors);
Expand Down

0 comments on commit 3855938

Please sign in to comment.