Skip to content

Commit

Permalink
chore(task): divides the import limits
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 6, 2024
1 parent 506f1a3 commit 16b144f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions functions/lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,33 @@ const handleWorker = async () => {
const storeIds = []
if (!notificationDocs.empty) {
const docsToRun = []
const docsImgToRun = []
notificationDocs.forEach(doc => {
if (docsToRun.length < 20) {
const data = doc.data()
const data = doc.data()
if (docsToRun.length < 30 && data.resource !== 'feed_import_image') {
if (queueState && queueState.store_ids && !queueState.store_ids.includes(data.store_id)) {
if (!storeIds.includes(data.store_id)) {
storeIds.push(data.store_id)
}
docsToRun.push(run(doc, data))
}
}

if (docsImgToRun.length < 5 && data.resource === 'feed_import_image') {
if (queueState && queueState.store_ids && !queueState.store_ids.includes(data.store_id)) {
if (!storeIds.includes(data.store_id)) {
storeIds.push(data.store_id)
}
docsImgToRun.push(run(doc, data))
}
}
})
queueControllerRef.doc(queueController.id).set({
running: true,
store_ids: storeIds
}, { merge: true })
await Promise.allSettled(docsToRun)
await Promise.allSettled(docsImgToRun)
}

queueControllerSnap = await queueControllerRef.get()
Expand Down

0 comments on commit 16b144f

Please sign in to comment.