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