Skip to content

Commit

Permalink
Continue RequestError
Browse files Browse the repository at this point in the history
  • Loading branch information
domoscargin committed Dec 19, 2024
1 parent 0ca0a4c commit 9849d43
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions build-filtered-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,36 +195,41 @@ async function filterDeps() {
console.log(`${performance.now()}: Analysis BEGIN`)

for (const repo of rawDeps.all_public_dependent_repos) {
console.log(`${performance.now()}: Getting repo data...`)
const repoData = await analyseRepo(repo)
if (repoData) {
builtData.push(repoData)
batchCounter++
}
console.log(`${performance.now()}: Analysis of ${repo.name} complete`)

const index = rawDeps.all_public_dependent_repos.findIndex(
(item) => item === repo
)
console.log(
`This was repo number ${index + 1} of ${
rawDeps.all_public_dependent_repos.length
}`
)
try {
console.log(`${performance.now()}: Getting repo data...`)
const repoData = await analyseRepo(repo)
if (repoData) {
builtData.push(repoData)
batchCounter++
}
console.log(`${performance.now()}: Analysis of ${repo.name} complete`)

const index = rawDeps.all_public_dependent_repos.findIndex(
(item) => item === repo
)
console.log(
`This was repo number ${index + 1} of ${
rawDeps.all_public_dependent_repos.length
}`
)

const remaining = await getRemainingRateLimit()
console.log(`${remaining} remaining on rate limit`)
}
if (batchCounter >= batchSize) {
await writeBatchToFiles(builtData)
builtData.length = 0
batchCounter = 0
}
const remaining = await getRemainingRateLimit()
console.log(`${remaining} remaining on rate limit`)
} catch (error) {
if (error instanceof RequestError) {
continue
}
}
if (batchCounter >= batchSize) {
await writeBatchToFiles(builtData)
builtData.length = 0
batchCounter = 0
}

if (builtData.length > 0) {
await writeBatchToFiles(builtData)
if (builtData.length > 0) {
await writeBatchToFiles(builtData)
}
}

console.log(`${performance.now()}: We're done!`)
}

Expand Down

0 comments on commit 9849d43

Please sign in to comment.