@@ -23,15 +23,41 @@ const password = 'ilikebigturtlesandicannotlie47';
2323
2424const org = await owner . createOrg ( ) ;
2525
26- console . log ( 'Create 100 projects' ) ;
26+ const ITEMS_COUNT = 100 ;
27+
28+ console . log ( `Create ${ ITEMS_COUNT } projects` ) ;
29+
2730await PromisePool . withConcurrency ( 10 )
2831 . for ( new Array ( 100 ) . fill ( null ) )
2932 . process ( ( ) => org . createProject ( ) ) ;
3033
31- console . log ( 'Create 100 organization members' ) ;
32- await PromisePool . withConcurrency ( 10 )
33- . for ( new Array ( 100 ) . fill ( null ) )
34- . process ( ( ) => org . inviteAndJoinMember ( ) ) ;
34+ console . log ( `Create ${ ITEMS_COUNT } organization members` ) ;
35+
36+ const RATE_LIMIT_COUNT = 6 ;
37+ const RATE_LIMIT_WINDOW_MS = 5000 ;
38+
39+ const members = new Array ( ITEMS_COUNT ) . fill ( null ) ;
40+
41+ // Split into batches of 6
42+ const batches = Array . from ( { length : Math . ceil ( members . length / RATE_LIMIT_COUNT ) } , ( _ , i ) =>
43+ members . slice ( i * RATE_LIMIT_COUNT , ( i + 1 ) * RATE_LIMIT_COUNT ) ,
44+ ) ;
45+
46+ // Process each batch sequentially, with items in batch processed concurrently
47+ for ( const [ index , batch ] of batches . entries ( ) ) {
48+ console . log ( `Processing batch ${ index + 1 } /${ batches . length } ...` ) ;
49+
50+ await PromisePool . withConcurrency ( RATE_LIMIT_COUNT )
51+ . for ( batch )
52+ . process ( ( ) => org . inviteAndJoinMember ( ) ) ;
53+
54+ // Wait between batches (except after the last one)
55+ if ( index < batches . length - 1 ) {
56+ await new Promise ( resolve => setTimeout ( resolve , RATE_LIMIT_WINDOW_MS ) ) ;
57+ }
58+ }
59+
60+ console . log ( `Completed creating ${ ITEMS_COUNT } organization members` ) ;
3561
3662console . log ( `
3763Seed User Credentials:
0 commit comments