@@ -22,7 +22,7 @@ const fetcher = (variables, token) => {
2222 return request (
2323 {
2424 query : `
25- query userInfo($login: String!) {
25+ query userInfo($login: String!, $ownerAffiliations: [RepositoryAffiliation] ) {
2626 user(login: $login) {
2727 name
2828 login
@@ -45,7 +45,7 @@ const fetcher = (variables, token) => {
4545 followers {
4646 totalCount
4747 }
48- repositories(ownerAffiliations: OWNER ) {
48+ repositories(ownerAffiliations: $ownerAffiliations ) {
4949 totalCount
5050 }
5151 }
@@ -70,9 +70,9 @@ const repositoriesFetcher = (variables, token) => {
7070 return request (
7171 {
7272 query : `
73- query userInfo($login: String!, $after: String) {
73+ query userInfo($login: String!, $after: String, $ownerAffiliations: [RepositoryAffiliation] ) {
7474 user(login: $login) {
75- repositories(first: 100, ownerAffiliations: OWNER , orderBy: {direction: DESC, field: STARGAZERS}, after: $after) {
75+ repositories(first: 100, ownerAffiliations: $ownerAffiliations , orderBy: {direction: DESC, field: STARGAZERS}, after: $after) {
7676 nodes {
7777 name
7878 stargazers {
@@ -141,15 +141,21 @@ const totalCommitsFetcher = async (username) => {
141141 * Fetch all the stars for all the repositories of a given username.
142142 *
143143 * @param {string } username GitHub username.
144+ * @param {boolean } include_orgs Include stats from organization repos.
144145 * @param {array } repoToHide Repositories to hide.
145146 * @returns {Promise<number> } Total stars.
146147 */
147- const totalStarsFetcher = async ( username , repoToHide ) => {
148+ const totalStarsFetcher = async ( username , include_orgs , repoToHide ) => {
148149 let nodes = [ ] ;
149150 let hasNextPage = true ;
150151 let endCursor = null ;
151152 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 : include_orgs ? [ "OWNER" , "COLLABORATOR" ] : [ "OWNER" ] ,
158+ } ;
153159 let res = await retryer ( repositoriesFetcher , variables ) ;
154160
155161 if ( res . data . errors ) {
@@ -183,12 +189,14 @@ const totalStarsFetcher = async (username, repoToHide) => {
183189 * @param {string } username GitHub username.
184190 * @param {boolean } count_private Include private contributions.
185191 * @param {boolean } include_all_commits Include all commits.
192+ * @param {boolean } include_orgs Include stats from organization repos.
186193 * @returns {Promise<import("./types").StatsData> } Stats data.
187194 */
188195const fetchStats = async (
189196 username ,
190197 count_private = false ,
191198 include_all_commits = false ,
199+ include_orgs = false ,
192200 exclude_repo = [ ] ,
193201) => {
194202 if ( ! username ) throw new MissingParamError ( [ "username" ] ) ;
@@ -203,7 +211,10 @@ const fetchStats = async (
203211 rank : { level : "C" , score : 0 } ,
204212 } ;
205213
206- let res = await retryer ( fetcher , { login : username } ) ;
214+ let res = await retryer ( fetcher , {
215+ login : username ,
216+ ownerAffiliations : include_orgs ? [ "OWNER" , "COLLABORATOR" ] : [ "OWNER" ] ,
217+ } ) ;
207218
208219 // Catch GraphQL errors.
209220 if ( res . data . errors ) {
@@ -259,7 +270,11 @@ const fetchStats = async (
259270 stats . contributedTo = user . repositoriesContributedTo . totalCount ;
260271
261272 // Retrieve stars while filtering out repositories to be hidden
262- stats . totalStars = await totalStarsFetcher ( username , repoToHide ) ;
273+ stats . totalStars = await totalStarsFetcher (
274+ username ,
275+ include_orgs ,
276+ repoToHide ,
277+ ) ;
263278
264279 stats . rank = calculateRank ( {
265280 totalCommits : stats . totalCommits ,
0 commit comments