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(
antes.map(async (ante) => {
const anteBetDoc = firestore const anteBetDoc = firestore
.collection(`contracts/${contract.id}/bets`) .collection(`contracts/${contract.id}/bets`)
.doc() .doc()
await anteBetDoc.set({ await anteBetDoc.set({
id: anteBetDoc.id, id: anteBetDoc.id,
...antes[i], ...ante,
}) })
} })
)
} }
} }