mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-01 14:46:41 +02:00
chore: Batch avatar download to avoid GitHub rate limiting.
This commit is contained in:
@@ -47,6 +47,7 @@ edgesep
|
|||||||
EMPTYSTR
|
EMPTYSTR
|
||||||
enddate
|
enddate
|
||||||
ERDIAGRAM
|
ERDIAGRAM
|
||||||
|
eslint
|
||||||
flatmap
|
flatmap
|
||||||
forwardable
|
forwardable
|
||||||
frontmatter
|
frontmatter
|
||||||
|
@@ -32,11 +32,17 @@ async function fetchAvatars() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
contributors = JSON.parse(await readFile(pathContributors, { encoding: 'utf-8' }));
|
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();
|
void fetchAvatars();
|
||||||
|
Reference in New Issue
Block a user