From 2bf363f056446c968c33b269840c3bc9281cfb24 Mon Sep 17 00:00:00 2001 From: Jannik Zinkl Date: Thu, 24 Oct 2024 15:40:36 +0200 Subject: [PATCH] fix: fixing tenancy operator to not always go to else --- .../src/products/index.ts | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/pkg/integration-kencove-api/src/products/index.ts b/pkg/integration-kencove-api/src/products/index.ts index 83705b0c..0c3ba8d2 100644 --- a/pkg/integration-kencove-api/src/products/index.ts +++ b/pkg/integration-kencove-api/src/products/index.ts @@ -1438,7 +1438,7 @@ export class KencoveApiAppProductSyncService { this.logger.info(`Found ${products.length} products to sync`); if (products.length === 0) { this.logger.info("No products to sync. Exiting."); - await this.cronState.set({ lastRun: new Date() }); + // await this.cronState.set({ lastRun: new Date() }); return; } @@ -1672,29 +1672,26 @@ export class KencoveApiAppProductSyncService { */ if ( existingProduct.normalizedName !== normalizedProductName || + existingProduct.name !== product.productName || existingProduct.descriptionHTML !== product.description || existingProduct.productTypeId !== kenProdTypeWithProductType.productTypeId || existingProduct.countryOfOrigin !== countryOfOrigin || - category - ? existingProduct.categoryId !== category - : false || - existingProduct.active !== product.active || - /** - * Compare the media arrays with each other and see, if we have other URLs - */ - !compareArraysWithoutOrder( - existingProduct.media.map((m) => ({ - url: m.url, - type: m.type, - })), - this.getTotalMediaFromProduct(product).map( - (m) => ({ - url: m.url, - type: m.type, - }), - ), - ) + (category && existingProduct.categoryId !== category) || + existingProduct.active !== product.active || + /** + * Compare the media arrays with each other and see, if we have other URLs + */ + !compareArraysWithoutOrder( + existingProduct.media.map((m) => ({ + url: m.url, + type: m.type, + })), + this.getTotalMediaFromProduct(product).map((m) => ({ + url: m.url, + type: m.type, + })), + ) ) { /** * log, which fields have changed @@ -1732,11 +1729,6 @@ export class KencoveApiAppProductSyncService { ), }, ); - console.log( - "CATEGORY", - existingProduct.categoryId, - category, - ); existingProduct = await this.updateProductSchemabase( product,