@@ -153,26 +153,28 @@ function allIncluded(outputTarget = 'email') {
153
153
154
154
// fetch github data
155
155
async function fetchGithubData ( ) {
156
+ const issueUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3Afossasia+created%3A${ startingDate } ..${ endingDate } &per_page=100` ;
157
+ const prUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3Afossasia+updated%3A${ startingDate } ..${ endingDate } &per_page=100` ;
158
+ const userUrl = `https://api.github.com/users/${ githubUsername } ` ;
159
+
156
160
try {
157
- const issueUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3Afossasia+created%3A${ startingDate } ..${ endingDate } &per_page=100` ;
158
- const prUrl = `https://api.github.com/search/issues?q=author%3A${ githubUsername } +org%3Afossasia+updated%3A${ startingDate } ..${ endingDate } &per_page=100` ;
159
- const userUrl = `https://api.github.com/users/${ githubUsername } ` ;
161
+ const [ issuesRes , prRes , userRes ] = await Promise . all ( [
162
+ fetch ( issueUrl ) ,
163
+ fetch ( prUrl ) ,
164
+ fetch ( userUrl ) ,
165
+ ] ) ;
160
166
161
- // Fetch issues
162
- const issuesRes = await fetch ( issueUrl ) ;
163
- if ( ! issuesRes . ok ) throw new Error ( `Error fetching Github issues: ${ issuesRes . status } ${ issuesRes . statusText } ` ) ;
164
- githubIssuesData = await issuesRes . json ( ) ;
165
- writeGithubIssuesPrs ( ) ;
167
+ if ( ! issuesRes . ok ) throw new Error ( `Error fetching Github issues: ${ issuesRes . status } ${ issuesRes . statusText } ` ) ;
168
+ if ( ! prRes . ok ) throw new Error ( `Error fetching Github PR review data: ${ prRes . status } ${ prRes . statusText } ` ) ;
169
+ if ( ! userRes . ok ) throw new Error ( `Error fetching Github userdata: ${ userRes . status } ${ userRes . statusText } ` ) ;
166
170
167
- // Fetch PR reviews
168
- const prRes = await fetch ( prUrl ) ;
169
- if ( ! prRes . ok ) throw new Error ( `Error fetching Github PR reviews: ${ prRes . status } ${ prRes . statusText } ` ) ;
171
+ githubIssuesData = await issuesRes . json ( ) ;
170
172
githubPrsReviewData = await prRes . json ( ) ;
173
+ githubUserData = await userRes . json ( ) ;
174
+
175
+ writeGithubIssuesPrs ( ) ;
171
176
writeGithubPrsReviews ( ) ;
172
177
173
- // Fetch github user data
174
- const userRes = await fetch ( userUrl ) ;
175
- if ( ! userRes . ok ) throw new Error ( `Error fetching Github user data: ${ userRes . status } ${ userRes . statusText } ` ) ;
176
178
} catch ( err ) {
177
179
console . error ( err ) ;
178
180
}
0 commit comments