Skip to content

Commit

Permalink
feat(productImport): adapt code to newest changes of reassignment mod…
Browse files Browse the repository at this point in the history
…ule (#116)
  • Loading branch information
lojzatran committed Aug 20, 2018
1 parent d011bb0 commit 44d7d7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
7 changes: 3 additions & 4 deletions lib/product-import.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ class ProductImport
@reassignmentService.execute(productsToProcess, @_cache.productType)
.then((res) =>
# if there are products which failed during reassignment, remove them from processing
if(res.failedSkus.length)
if(res.badRequestSKUs.length)
@logger.warn(
"Removing #{res.failedSkus} skus from processing due to a reassignment error"
"Removing #{res.badRequestSKUs} skus from processing due to a reassignment error"
)
productsToProcess = @_filterOutProductsBySkus(productsToProcess, res.failedSkus)
productsToProcess = @_filterOutProductsBySkus(productsToProcess, res.badRequestSKUs)
)
.then () =>
@_getExistingProductsForSkus(@_extractUniqueSkus(productsToProcess))
Expand All @@ -189,7 +189,6 @@ class ProductImport
.then =>
if @variantReassignmentOptions.enabled
@_summary.variantReassignment = @reassignmentService.statistics
console.log("TEMP_SUMMARY:", @_summary)

_getWhereQueryLimit: ->
client = @client.productProjections
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"bluebird": "^3.0.0",
"commercetools-node-variant-reassignment": "git://github.com/commercetools/commercetools-node-variant-reassignment.git#2-integrate-to-product-import",
"commercetools-node-variant-reassignment": "1.1.0",
"cuid": "^1.3.8",
"debug": "2.6.8",
"fs-extra": "3.0.1",
Expand Down
26 changes: 13 additions & 13 deletions test/integration/product-import.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,15 @@ describe 'Product Importer integration tests', ->
}
@import.performStream([productDraftChunk], Promise.resolve)
.then =>
expect(@import._summary.variantReassignment).toEqual({
anonymized: 1
productTypeChanged: 0,
processed: 1,
succeeded: 1,
retries: 0,
errors: 0,
processedSkus: [ 'sku4', 'sku3' ]
failedSkus: []
})
expect(@import._summary.variantReassignment.anonymized).toEqual(1)
expect(@import._summary.variantReassignment.productTypeChanged).toEqual(0)
expect(@import._summary.variantReassignment.processed).toEqual(1)
expect(@import._summary.variantReassignment.succeeded).toEqual(1)
expect(@import._summary.variantReassignment.transactionRetries).toEqual(0)
expect(@import._summary.variantReassignment.badRequestErrors).toEqual(0)
expect(@import._summary.variantReassignment.processedSkus).toEqual([ 'sku4', 'sku3' ])
expect(@import._summary.variantReassignment.badRequestSKUs).toEqual([])
expect(@import._summary.variantReassignment.anonymizedSlug.indexOf('no-category')).not.toEqual(1)

@fetchProducts(@productType.id)
.then ({ body: { results } }) =>
Expand Down Expand Up @@ -559,10 +558,11 @@ describe 'Product Importer integration tests', ->
productTypeChanged: 0,
processed: 1,
succeeded: 0,
retries: 0,
errors: 1,
transactionRetries: 0,
badRequestErrors: 1,
processedSkus: ['sku4', 'sku3']
failedSkus: ['sku4', 'sku3']
badRequestSKUs: ['sku4', 'sku3']
anonymizedSlug: []
})
done()
.catch (err) =>
Expand Down

0 comments on commit 44d7d7a

Please sign in to comment.