Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CNCF-Bot committed May 30, 2023
1 parent 0b66094 commit 8ce89db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/apiClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports.CrunchbaseClient = ApiClient({

module.exports.GithubClient = ApiClient({
baseURL: 'https://api.github.com',
retryStatuses: [403], // Github returns 403 when rate limiting.
retryStatuses: [401, 403], // Github returns 403 when rate limiting.
delayFn: error => {
const rateLimitRemaining = parseInt(_.get(error, ['response', 'headers', 'x-ratelimit-remaining'], 1))
const rateLimitReset = parseInt(_.get(error, ['response', 'headers', 'x-ratelimit-reset'], 1)) * 1000
Expand Down
24 changes: 14 additions & 10 deletions tools/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,20 @@ const fetchGithubOrgs = async preferCache => {
return { data: { url, repos, cached: true }, github_data, github_start_commit_data }
}
const orgName = url.split('/').pop()
const { description } = await GithubClient.request({ path: `orgs/${orgName}` })
const params = { type: 'public', per_page: 100 }
const path = `orgs/${orgName}/repos`
const response = await GithubClient.request({ path, params })
const repos = response.map(({ html_url, default_branch, size }) => {
if (size > 0) {
return { url: html_url, branch: default_branch, multiple: true }
}
}).filter(_ => _)
return { data: { url, repos }, github_data: { description } }
try {
const { description } = await GithubClient.request({ path: `orgs/${orgName}` })
const params = { type: 'public', per_page: 100 }
const path = `orgs/${orgName}/repos`
const response = await GithubClient.request({ path, params })
const repos = response.map(({ html_url, default_branch, size }) => {
if (size > 0) {
return { url: html_url, branch: default_branch, multiple: true }
}
}).filter(_ => _)
return { data: { url, repos }, github_data: { description } }
} catch(ex) {
console.info(`Failed to fetch org: ${orgName}`);
}
}, { concurrency: 10 })
}
module.exports.fetchGithubOrgs = fetchGithubOrgs;
Expand Down

0 comments on commit 8ce89db

Please sign in to comment.