mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
split inviteAndJoin into batches (#7298)
This commit is contained in:
parent
64c8368c4b
commit
7b07d1e374
1 changed files with 31 additions and 5 deletions
|
|
@ -23,15 +23,41 @@ const password = 'ilikebigturtlesandicannotlie47';
|
|||
|
||||
const org = await owner.createOrg();
|
||||
|
||||
console.log('Create 100 projects');
|
||||
const ITEMS_COUNT = 100;
|
||||
|
||||
console.log(`Create ${ITEMS_COUNT} projects`);
|
||||
|
||||
await PromisePool.withConcurrency(10)
|
||||
.for(new Array(100).fill(null))
|
||||
.process(() => org.createProject());
|
||||
|
||||
console.log('Create 100 organization members');
|
||||
await PromisePool.withConcurrency(10)
|
||||
.for(new Array(100).fill(null))
|
||||
.process(() => org.inviteAndJoinMember());
|
||||
console.log(`Create ${ITEMS_COUNT} organization members`);
|
||||
|
||||
const RATE_LIMIT_COUNT = 6;
|
||||
const RATE_LIMIT_WINDOW_MS = 5000;
|
||||
|
||||
const members = new Array(ITEMS_COUNT).fill(null);
|
||||
|
||||
// Split into batches of 6
|
||||
const batches = Array.from({ length: Math.ceil(members.length / RATE_LIMIT_COUNT) }, (_, i) =>
|
||||
members.slice(i * RATE_LIMIT_COUNT, (i + 1) * RATE_LIMIT_COUNT),
|
||||
);
|
||||
|
||||
// Process each batch sequentially, with items in batch processed concurrently
|
||||
for (const [index, batch] of batches.entries()) {
|
||||
console.log(`Processing batch ${index + 1}/${batches.length}...`);
|
||||
|
||||
await PromisePool.withConcurrency(RATE_LIMIT_COUNT)
|
||||
.for(batch)
|
||||
.process(() => org.inviteAndJoinMember());
|
||||
|
||||
// Wait between batches (except after the last one)
|
||||
if (index < batches.length - 1) {
|
||||
await new Promise(resolve => setTimeout(resolve, RATE_LIMIT_WINDOW_MS));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Completed creating ${ITEMS_COUNT} organization members`);
|
||||
|
||||
console.log(`
|
||||
Seed User Credentials:
|
||||
|
|
|
|||
Loading…
Reference in a new issue