Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitada9cf4

Browse files
authored
feat: add INCLUDE_ORGS env variable (anuraghazra#2275)
This commit adds an INCLUDE_ORGS ENV variable that can be used to include results fromorganizations into the GRS cards for self-deployed Vercel instances.**Warning**This is a hidden feature since we can not officially support this on the PublicVercel instance due to GraphQL and Vercel rate/timeout limits. You can set this envvariable via Vercel's ENV variable menu (seehttps://vercel.com/docs/concepts/projects/environment-variables).
1 parent3cb205c commitada9cf4

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

‎src/common/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const isValidHexColor = (hexColor) => {
7777
/**
7878
* Returns boolean if value is either "true" or "false" else the value as it is.
7979
*
80-
*@param {string | boolean} value The value to parse.
80+
*@param {string | boolean| undefined} value The value to parse.
8181
*@returns {boolean | undefined} The parsed value.
8282
*/
8383
constparseBoolean=(value)=>{

‎src/fetchers/stats-fetcher.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CustomError,
88
logger,
99
MissingParamError,
10+
parseBoolean,
1011
request,
1112
wrapTextMultiline,
1213
}from"../common/utils.js";
@@ -22,7 +23,7 @@ const fetcher = (variables, token) => {
2223
returnrequest(
2324
{
2425
query:`
25-
query userInfo($login: String!) {
26+
query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation]) {
2627
user(login: $login) {
2728
name
2829
login
@@ -45,7 +46,7 @@ const fetcher = (variables, token) => {
4546
followers {
4647
totalCount
4748
}
48-
repositories(ownerAffiliations:OWNER) {
49+
repositories(ownerAffiliations:$ownerAffiliations) {
4950
totalCount
5051
}
5152
}
@@ -70,9 +71,9 @@ const repositoriesFetcher = (variables, token) => {
7071
returnrequest(
7172
{
7273
query:`
73-
query userInfo($login: String!, $after: String) {
74+
query userInfo($login: String!, $after: String, $ownerAffiliations: [RepositoryAffiliation]) {
7475
user(login: $login) {
75-
repositories(first: 100, ownerAffiliations:OWNER, orderBy: {direction: DESC, field: STARGAZERS}, after: $after) {
76+
repositories(first: 100, ownerAffiliations:$ownerAffiliations, orderBy: {direction: DESC, field: STARGAZERS}, after: $after) {
7677
nodes {
7778
name
7879
stargazers {
@@ -149,7 +150,14 @@ const totalStarsFetcher = async (username, repoToHide) => {
149150
lethasNextPage=true;
150151
letendCursor=null;
151152
while(hasNextPage){
152-
constvariables={login:username,first:100,after:endCursor};
153+
constvariables={
154+
login:username,
155+
first:100,
156+
after:endCursor,
157+
ownerAffiliations:parseBoolean(process.env.INCLUDE_ORGS)
158+
?["OWNER","COLLABORATOR"]
159+
:["OWNER"],
160+
};
153161
letres=awaitretryer(repositoriesFetcher,variables);
154162

155163
if(res.data.errors){
@@ -203,7 +211,12 @@ const fetchStats = async (
203211
rank:{level:"C",score:0},
204212
};
205213

206-
letres=awaitretryer(fetcher,{login:username});
214+
letres=awaitretryer(fetcher,{
215+
login:username,
216+
ownerAffiliations:parseBoolean(process.env.INCLUDE_ORGS)
217+
?["OWNER","COLLABORATOR"]
218+
:["OWNER"],
219+
});
207220

208221
// Catch GraphQL errors.
209222
if(res.data.errors){

‎src/fetchers/top-languages-fetcher.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
CustomError,
55
logger,
66
MissingParamError,
7+
parseBoolean,
78
request,
89
wrapTextMultiline,
910
}from"../common/utils.js";
@@ -19,10 +20,10 @@ const fetcher = (variables, token) => {
1920
returnrequest(
2021
{
2122
query:`
22-
query userInfo($login: String!) {
23+
query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation]) {
2324
user(login: $login) {
2425
# fetch only owner repos & not forks
25-
repositories(ownerAffiliations:OWNER, isFork: false, first: 100) {
26+
repositories(ownerAffiliations:$ownerAffiliations, isFork: false, first: 100) {
2627
nodes {
2728
name
2829
languages(first: 10, orderBy: {field: SIZE, direction: DESC}) {
@@ -57,7 +58,12 @@ const fetcher = (variables, token) => {
5758
constfetchTopLanguages=async(username,exclude_repo=[])=>{
5859
if(!username)thrownewMissingParamError(["username"]);
5960

60-
constres=awaitretryer(fetcher,{login:username});
61+
constres=awaitretryer(fetcher,{
62+
login:username,
63+
ownerAffiliations:parseBoolean(process.env.INCLUDE_ORGS)
64+
?["OWNER","COLLABORATOR"]
65+
:["OWNER"],
66+
});
6167

6268
if(res.data.errors){
6369
logger.error(res.data.errors);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp