From 7cd2f8a3b2fcd95691ee5f3e93a4cbaaec689446 Mon Sep 17 00:00:00 2001 From: Ede Somogyi Date: Tue, 18 Jul 2023 18:04:44 +0300 Subject: [PATCH 1/3] Clarified newURL usage --- .../cartridge/static/default/js/algolia/autocomplete-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cartridges/int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js b/cartridges/int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js index 955cec21..db89585a 100644 --- a/cartridges/int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js +++ b/cartridges/int_algolia_sfra/cartridge/static/default/js/algolia/autocomplete-config.js @@ -64,7 +64,7 @@ function enableAutocomplete(config) { return html`
- ${components.Highlight({ hit: item, attribute: "name", tagName: "em" })} + ${components.Highlight({ hit: item, attribute: "name", tagName: "em" })}
`; }, }, From aa242865d863b32532e40ae32002d755f2661c73 Mon Sep 17 00:00:00 2001 From: Ede Somogyi Date: Tue, 18 Jul 2023 18:19:56 +0300 Subject: [PATCH 2/3] Spelling and various other fixes --- .../algoliabm/dashboard/categoryLog.isml | 4 +-- .../algoliabm/dashboard/productLog.isml | 4 +-- .../templates/resources/algolia.properties | 10 +++--- .../scripts/algolia/helper/logHelper.js | 6 ++-- .../scripts/algolia/helper/sendDelta.js | 34 +++++++++---------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/categoryLog.isml b/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/categoryLog.isml index f5d3a4b1..66ea78b3 100644 --- a/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/categoryLog.isml +++ b/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/categoryLog.isml @@ -116,7 +116,7 @@ - + @@ -124,7 +124,7 @@ - + diff --git a/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/productLog.isml b/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/productLog.isml index 7270663b..10f59d7b 100644 --- a/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/productLog.isml +++ b/cartridges/bm_algolia/cartridge/templates/default/algoliabm/dashboard/productLog.isml @@ -116,7 +116,7 @@ - + @@ -124,7 +124,7 @@ - + diff --git a/cartridges/bm_algolia/cartridge/templates/resources/algolia.properties b/cartridges/bm_algolia/cartridge/templates/resources/algolia.properties index e4dd9e54..ce2e7998 100644 --- a/cartridges/bm_algolia/cartridge/templates/resources/algolia.properties +++ b/cartridges/bm_algolia/cartridge/templates/resources/algolia.properties @@ -12,12 +12,12 @@ algolia.label.errmessage=Error Message: algolia.label.lastsentdate=Last sent Date algolia.label.sentsuccessfully=Data sent successfully algolia.label.sentfailed=Failed to send data -algolia.label.category.title.processed=Log of the last processed Categories data -algolia.label.category.title.sent=Log of the last sent Category data +algolia.label.category.title.processed=Category export - last processed +algolia.label.category.title.sent=Category export - last sent algolia.label.category.processed=Categories processed algolia.label.category.toupdate=Categories ready for update -algolia.label.product.title.processed=Log of the last processed Products data -algolia.label.product.title.sent=Log of the last sent Product data +algolia.label.product.title.processed=Product export - last processed +algolia.label.product.title.sent=Product export - last sent algolia.label.product.processed=Products processed algolia.label.product.toupdate=Products ready for update algolia.label.preference.name=Preference Name @@ -29,7 +29,7 @@ algolia.label.preference.baseurl=Read Host Base Url algolia.label.preference.instock=InStock Threshold algolia.label.preference.custom=Custom Fields algolia.label.preference.indexprefix=Index Prefix. If set, it replaces the default index prefix: < hostname >__< siteID > -algolia.label.preference.enablessr=Enable server-side rendering for CLP (category landing page) results. Improves SEO but minimally increases page load times. +algolia.label.preference.enablessr=Enable server-side rendering for CLP (category landing page) results. Improves SEO but slightly increases page load times. algolia.label.preference.clientid=OCAPI Client ID algolia.label.preference.clientpassword=OCAPI Client password algolia.label.button.apply=Apply diff --git a/cartridges/int_algolia/cartridge/scripts/algolia/helper/logHelper.js b/cartridges/int_algolia/cartridge/scripts/algolia/helper/logHelper.js index 56feef1f..ecbb1b8e 100644 --- a/cartridges/int_algolia/cartridge/scripts/algolia/helper/logHelper.js +++ b/cartridges/int_algolia/cartridge/scripts/algolia/helper/logHelper.js @@ -23,9 +23,9 @@ function LogJob() { this.sendDate = '---'; this.sendError = false; this.sendErrorMessage = ''; - this.sendedChunk = 0; - this.sendedRecords = 0; - this.failedChunk = 0; + this.sentChunks = 0; + this.sentRecords = 0; + this.failedChunks = 0; this.failedRecords = 0; } diff --git a/cartridges/int_algolia/cartridge/scripts/algolia/helper/sendDelta.js b/cartridges/int_algolia/cartridge/scripts/algolia/helper/sendDelta.js index 7f53b993..35ffa7ca 100644 --- a/cartridges/int_algolia/cartridge/scripts/algolia/helper/sendDelta.js +++ b/cartridges/int_algolia/cartridge/scripts/algolia/helper/sendDelta.js @@ -56,14 +56,14 @@ function sendDelta(deltaList, logID, parameters) { sendLogData.sendDate = algoliaData.getLocalDateTime(new Date()); sendLogData.sendError = true; sendLogData.sendErrorMessage = ''; - sendLogData.sendedChunk = 0; - sendLogData.sendedRecords = 0; - sendLogData.failedChunk = 0; + sendLogData.sentChunks = 0; + sendLogData.sentRecords = 0; + sendLogData.failedChunks = 0; sendLogData.failedRecords = 0; var entries = []; var failedChunks = []; - var countFailedShunks = 0; + var countFailedChunks = 0; var status = new Status(Status.OK); @@ -79,10 +79,10 @@ function sendDelta(deltaList, logID, parameters) { var inputMaxNumberOfEntries = Object.hasOwnProperty.call(parameters, 'maxNumberOfEntries') ? parseInt(parameters.maxNumberOfEntries, 10) : MAX_CHUNKS_SIZE; // calculate it - var calkMaxNumberOfEntries = Math.floor(QUOTA_API_JS_JSON_STRING_LENGTH / deltaList.getRecordSize()); // number of objects to fit the quota - calkMaxNumberOfEntries -= Math.floor(calkMaxNumberOfEntries / 5); // reduce by 20% + var calcMaxNumberOfEntries = Math.floor(QUOTA_API_JS_JSON_STRING_LENGTH / deltaList.getRecordSize()); // number of objects to fit the quota + calcMaxNumberOfEntries -= Math.floor(calcMaxNumberOfEntries / 5); // reduce by 20% - var maxNumberOfEntries = Math.min(inputMaxNumberOfEntries, calkMaxNumberOfEntries); + var maxNumberOfEntries = Math.min(inputMaxNumberOfEntries, calcMaxNumberOfEntries); while (deltaList.hasNext()) { entries.push(deltaList.next()); @@ -92,12 +92,12 @@ function sendDelta(deltaList, logID, parameters) { status = sendChunk(entries); if (status.error) { failedChunks = failedChunks.concat(entries); - countFailedShunks += 1; - sendLogData.failedChunk += 1; + countFailedChunks += 1; + sendLogData.failedChunks += 1; sendLogData.failedRecords += entries.length; sendLogData.sendErrorMessage = status.details.errorMessage ? status.details.errorMessage : 'Error sending chunk. See the log file for details.'; - if (countFailedShunks > MAX_FAILED_CHUNKS) { + if (countFailedChunks > MAX_FAILED_CHUNKS) { sendLogData.sendError = true; sendLogData.sendErrorMessage = 'Too many failed chunks. Service might be down. Aborting the job.'; algoliaData.setLogData(logID, sendLogData); @@ -105,8 +105,8 @@ function sendDelta(deltaList, logID, parameters) { return status; } } else { - sendLogData.sendedChunk += 1; - sendLogData.sendedRecords += entries.length; + sendLogData.sentChunks += 1; + sendLogData.sentRecords += entries.length; } entries.length = 0; // crear the array } @@ -122,17 +122,17 @@ function sendDelta(deltaList, logID, parameters) { sendLogData.sendErrorMessage = status.details.errorMessage ? status.details.errorMessage : 'Error sending chunk. See the log file for details.'; } else { sendLogData.sendError = false; - sendLogData.sendedChunk += sendLogData.failedChunk; - sendLogData.sendedRecords += sendLogData.failedRecords; - sendLogData.failedChunk = 0; + sendLogData.sentChunks += sendLogData.failedChunks; + sendLogData.sentRecords += sendLogData.failedRecords; + sendLogData.failedChunks = 0; sendLogData.failedRecords = 0; } sendLogData.sendDate = algoliaData.getLocalDateTime(new Date()); algoliaData.setLogData(logID, sendLogData); - logger.info('Chunk(s) sent: {0}; Failed chunk(s): {1}\nRecord(s) sent: {2}; Failed record(s): {3}', - sendLogData.sendedChunk, sendLogData.failedChunk, sendLogData.sendedRecords, sendLogData.failedRecords); + logger.info('Chunks sent: {0}; Failed chunks: {1}\nRecords sent: {2}; Failed records: {3}', + sendLogData.sentChunks, sendLogData.failedChunks, sendLogData.sentRecords, sendLogData.failedRecords); return status; } From 377a7d069401e3082c91149f1ddb84ad5e55846e Mon Sep 17 00:00:00 2001 From: Ede Somogyi Date: Tue, 18 Jul 2023 19:48:33 +0300 Subject: [PATCH 3/3] Added updateLogType constant --- .../scripts/algolia/job/categoryIndexJob.js | 10 ++++++---- .../scripts/algolia/job/productsIndexJob.js | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cartridges/int_algolia/cartridge/scripts/algolia/job/categoryIndexJob.js b/cartridges/int_algolia/cartridge/scripts/algolia/job/categoryIndexJob.js index c3d11752..b2f6560f 100644 --- a/cartridges/int_algolia/cartridge/scripts/algolia/job/categoryIndexJob.js +++ b/cartridges/int_algolia/cartridge/scripts/algolia/job/categoryIndexJob.js @@ -224,7 +224,9 @@ function runCategoryExport(parameters) { ? siteRootCategory.getOnlineSubCategories().iterator() : null; var listOfCategories = []; - var categoryLogData = algoliaData.getLogData('LastCategorySyncLog'); + const updateLogType = 'LastCategorySyncLog'; + + var categoryLogData = algoliaData.getLogData(updateLogType); categoryLogData.processedDate = algoliaData.getLocalDateTime(new Date()); categoryLogData.processedError = true; categoryLogData.processedErrorMessage = ''; @@ -240,7 +242,7 @@ function runCategoryExport(parameters) { if (!algoliaData.getPreference('Enable')) { jobHelper.logFileError('Disable', 'Algolia Cartridge Disabled', status); categoryLogData.processedErrorMessage = 'Algolia Cartridge Disabled'; - algoliaData.setLogData('LastCategorySyncLog', categoryLogData); + algoliaData.setLogData(updateLogType, categoryLogData); return status; } @@ -266,7 +268,7 @@ function runCategoryExport(parameters) { } catch (error) { jobHelper.logFileError(snapshotFile.fullPath, 'Error remove snapshot file', error); categoryLogData.processedErrorMessage = 'Error remove shapnshot file'; - algoliaData.setLogData('LastCategorySyncLog', categoryLogData); + algoliaData.setLogData(updateLogType, categoryLogData); return new Status(Status.ERROR); } } @@ -370,7 +372,7 @@ function runCategoryExport(parameters) { categoryLogData.processedErrorMessage = ''; categoryLogData.processedRecords = counterCategoriesTotal; categoryLogData.processedToUpdateRecords = counterCategoriesForUpdate; - algoliaData.setLogData('LastCategorySyncLog', categoryLogData); + algoliaData.setLogData(updateLogType, categoryLogData); return new Status(Status.OK); } diff --git a/cartridges/int_algolia/cartridge/scripts/algolia/job/productsIndexJob.js b/cartridges/int_algolia/cartridge/scripts/algolia/job/productsIndexJob.js index fd181edf..631fba3b 100644 --- a/cartridges/int_algolia/cartridge/scripts/algolia/job/productsIndexJob.js +++ b/cartridges/int_algolia/cartridge/scripts/algolia/job/productsIndexJob.js @@ -78,9 +78,11 @@ function runProductExport(parameters) { var algoliaData = require('*/cartridge/scripts/algolia/lib/algoliaData'); var fileReadIterator = require('*/cartridge/scripts/algolia/helper/fileReadIterator'); + const updateLogType = 'LastProductSyncLog'; + var counterProductsTotal = 0; var counterProductsForUpdate = 0; - var productLogData = algoliaData.getLogData('LastProductSyncLog'); + var productLogData = algoliaData.getLogData(updateLogType); productLogData.processedDate = algoliaData.getLocalDateTime(new Date()); productLogData.processedError = true; productLogData.processedErrorMessage = ''; @@ -96,7 +98,7 @@ function runProductExport(parameters) { if (!algoliaData.getPreference('Enable')) { jobHelper.logFileError('Disable', 'Algolia Cartridge Disabled', status); productLogData.processedErrorMessage = 'Algolia Cartridge Disabled'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); return status; } @@ -129,7 +131,7 @@ function runProductExport(parameters) { } catch (error) { jobHelper.logFileError(updateFile.fullPath, 'Error open Delta file to write', error); productLogData.processedErrorMessage = 'Error open Delta file to write'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); snapshotFileWriter.close(); snapshotXmlWriter.close(); return new Status(Status.ERROR); @@ -145,7 +147,7 @@ function runProductExport(parameters) { } catch (error) { jobHelper.logFileError(snapshotFile.fullPath, 'Error remove file', error); productLogData.processedErrorMessage = 'Error remove file'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); snapshotFileWriter.close(); snapshotXmlWriter.close(); updateFileWriter.close(); @@ -156,7 +158,7 @@ function runProductExport(parameters) { snapshotReadIterator = fileReadIterator.create(algoliaConstants.SNAPSHOT_PRODUCTS_FILE_NAME, 'product'); if (empty(snapshotReadIterator)) { productLogData.processedErrorMessage = 'Error open Snapshot file or read'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); snapshotFileWriter.close(); snapshotXmlWriter.close(); updateFileWriter.close(); @@ -181,7 +183,7 @@ function runProductExport(parameters) { } catch (error) { jobHelper.logFileError(newSnapshotFile.fullPath, 'Error write to file', error); productLogData.processedErrorMessage = 'Error write to file'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); snapshotFileWriter.close(); snapshotXmlWriter.close(); updateFileWriter.close(); @@ -258,7 +260,7 @@ function runProductExport(parameters) { } catch (error) { jobHelper.logFileError(updateFile.fullPath, 'Error write to file', error); productLogData.processedErrorMessage = 'Error write to file'; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); snapshotFileWriter.close(); snapshotXmlWriter.close(); updateFileWriter.close(); @@ -300,7 +302,7 @@ function runProductExport(parameters) { productLogData.processedErrorMessage = ''; productLogData.processedRecords = counterProductsTotal; productLogData.processedToUpdateRecords = counterProductsForUpdate; - algoliaData.setLogData('LastProductSyncLog', productLogData); + algoliaData.setLogData(updateLogType, productLogData); return new Status(Status.OK); }