Parallelize ante creation

This commit is contained in:
James Grugett 2022-05-06 16:23:01 -04:00
parent e01c7bd763
commit d99928d16e

View File

@ -121,7 +121,7 @@ export const createContract = functions
closeTime, closeTime,
tags ?? [], tags ?? [],
100, 100,
1, 0,
100 100
) )
@ -188,16 +188,18 @@ export const createContract = functions
ante ante
) )
for (let i = 0; i < antes.length; i++) { await Promise.all(
const anteBetDoc = firestore antes.map(async (ante) => {
.collection(`contracts/${contract.id}/bets`) const anteBetDoc = firestore
.doc() .collection(`contracts/${contract.id}/bets`)
.doc()
await anteBetDoc.set({ await anteBetDoc.set({
id: anteBetDoc.id, id: anteBetDoc.id,
...antes[i], ...ante,
})
}) })
} )
} }
} }