Skip to content

Commit

Permalink
fix(task): import one table at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 9, 2024
1 parent 55f242d commit 0715b65
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions functions/lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,24 +233,28 @@ const handleWorker = async () => {
notificationDocs.forEach(doc => {
const data = doc.data()
if (docsToRun.length < limitDocs) {
let isPushDoc = true
if (queueState && queueState.store_ids && !queueState.store_ids.includes(data.store_id)) {
if (!storeIds.includes(data.store_id)) {
storeIds.push(data.store_id)
}
if (data.resource === 'feed_import_image') {
logger.info(`data: ${JSON.stringify(data)}`)
const quantityImgs = data.body?.imageLinks?.length
limitDocs -= quantityImgs || 0
logger.info(`limit:${limitDocs}`)
} else if (data.resource === 'feed_import_table') {
isPushDoc = limitDocs > 20
limitDocs = isPushDoc ? 0 : limitDocs
}
if (isPushDoc) {
docsToRun.push(
run(doc, data)
.catch((err) => {
// Todo: remove debug
logger.error(err)
throw err
})
)
}
docsToRun.push(
run(doc, data)
.catch((err) => {
// Todo: remove debug
logger.error(err)
throw err
})
)
}
}
})
Expand Down

0 comments on commit 0715b65

Please sign in to comment.