Skip to content

Commit

Permalink
fix(import-product): remove function images queue
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 11, 2024
1 parent 9600aa4 commit ce83dd7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 225 deletions.
61 changes: 0 additions & 61 deletions functions/lib/integration/handle-images/import-images.js

This file was deleted.

152 changes: 0 additions & 152 deletions functions/lib/integration/handle-images/utils.js

This file was deleted.

7 changes: 4 additions & 3 deletions functions/lib/integration/import-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ module.exports = ({ appSdk, storeId, auth }, tinyToken, queueEntry, appData, can
const arvoreCategoria = tinyStockUpdate?.produto?.arvoreCategoria
if (newProductId) {
await importCategoriesFromTiny({ appSdk, storeId, auth }, newProductId, arvoreCategoria)
.catch(logger.error)
.catch(logger.warn)
}
}

logger.info('Produto criado com sucesso')
return response
}).catch(err => {
err.storeId = storeId
logger.info(err)
logger.warn(err)
throw err
})
})
} else if (!tinyProduct || !produto) {
Expand Down Expand Up @@ -227,7 +228,7 @@ module.exports = ({ appSdk, storeId, auth }, tinyToken, queueEntry, appData, can
const arvoreCategoria = tinyStockUpdate?.produto?.arvoreCategoria
if (productId) {
await importCategoriesFromTiny({ appSdk, storeId, auth }, productId, arvoreCategoria)
.catch(logger.error)
.catch(logger.warn)
}
}
return response
Expand Down
19 changes: 10 additions & 9 deletions functions/lib/integration/parsers/product-to-ecomplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const removeAccents = str => str.replace(/áàãâÁÀÃÂ/g, 'a')
.replace(/úÚ/g, 'u')
.replace(/çÇ/g, 'c')

const tryImageUpload = (storeId, auth, originImgUrl, product, index) => new Promise(resolve => {
const tryImageUpload = (storeId, auth, originImgUrl, product, index) => new Promise((resolve, reject) => {
axios.get(originImgUrl, {
responseType: 'arraybuffer'
})
Expand Down Expand Up @@ -54,14 +54,15 @@ const tryImageUpload = (storeId, auth, originImgUrl, product, index) => new Prom
})

.catch(err => {
console.error(err)
resolve({
_id: ecomUtils.randomObjectId(),
normal: {
url: originImgUrl,
alt: product.name
}
})
reject(err)
// console.error(err)
// resolve({
// _id: ecomUtils.randomObjectId(),
// normal: {
// url: originImgUrl,
// alt: product.name
// }
// })
})
}).then(picture => {
if (product && product.pictures) {
Expand Down

0 comments on commit ce83dd7

Please sign in to comment.