File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -161,12 +161,17 @@ export async function incrementEloCronJobAllQueues() {
161161 const matchupUsers = bestPair . map ( ( u ) => u . userId )
162162
163163 // remove users from all queues they are in
164- for ( const userId of matchupUsers ) {
165- const userQueues = await getUserQueues ( userId )
166- for ( const queue of userQueues ) {
167- await removeUserFromQueue ( queue . id , userId )
168- }
169- }
164+ // Wait for all removal operations to complete before creating match
165+ await Promise . all (
166+ matchupUsers . map ( async ( userId ) => {
167+ const userQueues = await getUserQueues ( userId )
168+ await Promise . all (
169+ userQueues . map ( ( queue ) =>
170+ removeUserFromQueue ( queue . id , userId ) ,
171+ ) ,
172+ )
173+ } ) ,
174+ )
170175
171176 // queue them for the match
172177 await createMatch ( matchupUsers , bestPair [ 0 ] . queueId )
You can’t perform that action at this time.
0 commit comments