@@ -19,11 +19,10 @@ async function fetchOpenCollectiveData() {
1919 const members = payload
2020 . filter ( ( { role, isActive } ) => role === 'BACKER' && isActive )
2121 . sort ( ( a , b ) => b . totalAmountDonated - a . totalAmountDonated )
22- . map ( ( { name, website , image, profile } ) => ( {
22+ . map ( ( { name, image, profile } ) => ( {
2323 name,
2424 image,
25- url : website ,
26- profile,
25+ url : profile ,
2726 source : 'opencollective' ,
2827 } ) ) ;
2928
@@ -66,8 +65,9 @@ async function fetchGithubSponsorsData() {
6665 id : s ?. id || null ,
6766 login : s ?. login || null ,
6867 name : s ?. name || s ?. login || null ,
69- avatar : s ?. avatarUrl || null ,
70- url : s ?. websiteUrl || s ?. url || null ,
68+ image : s ?. avatarUrl || null ,
69+ url : s ?. url || null ,
70+ source : 'github' ,
7171 } ;
7272 } ) ;
7373
@@ -80,6 +80,28 @@ async function fetchGithubSponsorsData() {
8080 cursor = pageInfo . endCursor ;
8181 }
8282
83+ const query = donationsQuery ( ) ;
84+ const data = await graphql ( query ) ;
85+
86+ if ( data . errors ) {
87+ throw new Error ( JSON . stringify ( data . errors ) ) ;
88+ }
89+
90+ const nodeRes = data . data . organization ?. sponsorsActivities ;
91+
92+ const { nodes } = nodeRes ;
93+ const mapped = nodes . map ( n => {
94+ const s = n . sponsor || n . sponsorEntity || n . sponsorEntity ; // support different field names
95+ return {
96+ name : s ?. name || s ?. login || null ,
97+ image : s ?. avatarUrl || null ,
98+ url : s ?. url || null ,
99+ source : 'github' ,
100+ } ;
101+ } ) ;
102+
103+ sponsors . push ( ...mapped ) ;
104+
83105 return sponsors ;
84106}
85107
@@ -119,37 +141,41 @@ function sponsorshipsQuery(cursor = null) {
119141 }` ;
120142}
121143
122- // function donationsQuery(cursor = null) {
123- // return `
124- // query {
125- // organization(login: "nodejs") {
126- // sponsorsActivities (first: 100, includePrivate: false, after: "${cursor}") {
127- // nodes {
128- // id
129- // sponsor {
130- // ...on User {
131- // id: databaseId,
132- // name,
133- // login,
134- // avatarUrl,
135- // url,
136- // websiteUrl
137- // }
138- // ...on Organization {
139- // id: databaseId,
140- // name,
141- // login,
142- // avatarUrl,
143- // url,
144- // websiteUrl
145- // }
146- // },
147- // timestamp
148- // }
149- // }
150- // }
151- // }`;
152- // }
144+ function donationsQuery ( ) {
145+ return `
146+ query {
147+ organization(login: "nodejs") {
148+ sponsorsActivities (first: 100, includePrivate: false) {
149+ nodes {
150+ id
151+ sponsor {
152+ ...on User {
153+ id: databaseId,
154+ name,
155+ login,
156+ avatarUrl,
157+ url,
158+ websiteUrl
159+ }
160+ ...on Organization {
161+ id: databaseId,
162+ name,
163+ login,
164+ avatarUrl,
165+ url,
166+ websiteUrl
167+ }
168+ },
169+ timestamp
170+ tier: sponsorsTier {
171+ monthlyPriceInDollars,
172+ isOneTime
173+ }
174+ }
175+ }
176+ }
177+ }` ;
178+ }
153179
154180const graphql = async ( query , variables = { } ) => {
155181 const res = await fetch ( GITHUB_GRAPHQL_URL , {
@@ -180,6 +206,7 @@ async function sponsorsData() {
180206 fetchGithubSponsorsData ( ) ,
181207 fetchOpenCollectiveData ( ) ,
182208 ] ) ;
209+
183210 return sponsors . flat ( ) ;
184211}
185212
0 commit comments