Tweak logic of calling cloud functions in batches
This commit is contained in:
parent
c880e164f9
commit
65a8042414
|
@ -24,10 +24,12 @@ export const updateRecommendations = functions.pubsub
|
|||
userBatches.push(users.slice(i, i + batchSize))
|
||||
}
|
||||
|
||||
for (const batch of userBatches) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||
callCloudFunction('updateRecommendationsBatch', { users: batch })
|
||||
}
|
||||
await Promise.all(
|
||||
userBatches.map(async (batch, i) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 100 * i))
|
||||
await callCloudFunction('updateRecommendationsBatch', { users: batch })
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
export const updateRecommendationsBatch = functions.https.onCall(
|
||||
|
|
|
@ -28,10 +28,12 @@ export const updateFeed = functions.pubsub
|
|||
const contracts = await getFeedContracts()
|
||||
const users = await getValues<User>(firestore.collection('users'))
|
||||
|
||||
for (const user of users) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10))
|
||||
callCloudFunction('updateUserFeed', { user, contracts })
|
||||
}
|
||||
await Promise.all(
|
||||
users.map(async (user, i) => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 10 * i))
|
||||
await callCloudFunction('updateUserFeed', { user, contracts })
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
export const updateUserFeed = functions.https.onCall(
|
||||
|
|
Loading…
Reference in New Issue
Block a user