7
7
CustomError ,
8
8
logger ,
9
9
MissingParamError ,
10
+ parseBoolean ,
10
11
request ,
11
12
wrapTextMultiline ,
12
13
} from "../common/utils.js" ;
@@ -22,7 +23,7 @@ const fetcher = (variables, token) => {
22
23
return request (
23
24
{
24
25
query : `
25
- query userInfo($login: String!) {
26
+ query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation] ) {
26
27
user(login: $login) {
27
28
name
28
29
login
@@ -45,7 +46,7 @@ const fetcher = (variables, token) => {
45
46
followers {
46
47
totalCount
47
48
}
48
- repositories(ownerAffiliations: OWNER ) {
49
+ repositories(ownerAffiliations: $ownerAffiliations ) {
49
50
totalCount
50
51
}
51
52
}
@@ -70,9 +71,9 @@ const repositoriesFetcher = (variables, token) => {
70
71
return request (
71
72
{
72
73
query : `
73
- query userInfo($login: String!, $after: String) {
74
+ query userInfo($login: String!, $after: String, $ownerAffiliations: [RepositoryAffiliation] ) {
74
75
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) {
76
77
nodes {
77
78
name
78
79
stargazers {
@@ -149,7 +150,14 @@ const totalStarsFetcher = async (username, repoToHide) => {
149
150
let hasNextPage = true ;
150
151
let endCursor = null ;
151
152
while ( hasNextPage ) {
152
- const variables = { login : username , first : 100 , after : endCursor } ;
153
+ const variables = {
154
+ login : username ,
155
+ first : 100 ,
156
+ after : endCursor ,
157
+ ownerAffiliations : parseBoolean ( process . env . INCLUDE_ORGS )
158
+ ? [ "OWNER" , "COLLABORATOR" ]
159
+ : [ "OWNER" ] ,
160
+ } ;
153
161
let res = await retryer ( repositoriesFetcher , variables ) ;
154
162
155
163
if ( res . data . errors ) {
@@ -203,7 +211,12 @@ const fetchStats = async (
203
211
rank : { level : "C" , score : 0 } ,
204
212
} ;
205
213
206
- let res = await retryer ( fetcher , { login : username } ) ;
214
+ let res = await retryer ( fetcher , {
215
+ login : username ,
216
+ ownerAffiliations : parseBoolean ( process . env . INCLUDE_ORGS )
217
+ ? [ "OWNER" , "COLLABORATOR" ]
218
+ : [ "OWNER" ] ,
219
+ } ) ;
207
220
208
221
// Catch GraphQL errors.
209
222
if ( res . data . errors ) {
0 commit comments