chore: Batch avatar download to avoid GitHub rate limiting.

This commit is contained in:
Sidharth Vinod
2025-05-07 12:24:29 +05:30
parent 05c74ed9ce
commit 84faddc9e5
2 changed files with 11 additions and 4 deletions

View File

@@ -47,6 +47,7 @@ edgesep
EMPTYSTR
enddate
ERDIAGRAM
eslint
flatmap
forwardable
frontmatter

View File

@@ -32,11 +32,17 @@ async function fetchAvatars() {
});
contributors = JSON.parse(await readFile(pathContributors, { encoding: 'utf-8' }));
const avatars = contributors.map((name) =>
download(`https://github.com/${name}.png?size=100`, getAvatarPath(name))
);
await Promise.allSettled(avatars);
const batchSize = 10;
for (let i = 0; i < contributors.length; i += batchSize) {
console.log(
`Processing batch ${i / batchSize + 1} of ${Math.ceil(contributors.length / batchSize)}`
);
const batch = contributors.slice(i, i + batchSize);
await Promise.allSettled(
batch.map((name) => download(`https://github.com/${name}.png?size=100`, getAvatarPath(name)))
);
}
}
void fetchAvatars();