mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
chore: Batch avatar download to avoid GitHub rate limiting.
This commit is contained in:
@@ -47,6 +47,7 @@ edgesep
|
||||
EMPTYSTR
|
||||
enddate
|
||||
ERDIAGRAM
|
||||
eslint
|
||||
flatmap
|
||||
forwardable
|
||||
frontmatter
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user