From 1d998b7fe0718ecfc547afe5630bbf8df1731887 Mon Sep 17 00:00:00 2001 From: Arshad Mohammed <87503056+arshadparwaiz@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:20:54 -0800 Subject: [PATCH] Added Excel Update & logging (#35) --- actions/graybox/initiate-promote-worker.js | 11 +++++------ actions/graybox/preview-worker.js | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/actions/graybox/initiate-promote-worker.js b/actions/graybox/initiate-promote-worker.js index ae946f5..cf91884 100644 --- a/actions/graybox/initiate-promote-worker.js +++ b/actions/graybox/initiate-promote-worker.js @@ -139,12 +139,12 @@ async function main(params) { projectQueue.push(newProject); } - logger.info(`In Initiate Preview Worker, Project Queue Json: ${JSON.stringify(projectQueue)}`); + logger.info(`In Initiate Promote Worker, Project Queue Json: ${JSON.stringify(projectQueue)}`); // Create Project Status JSON const projectStatusJson = { status: 'initiated', params: inputParams }; - logger.info(`In Initiate Preview Worker, projectStatusJson: ${JSON.stringify(projectStatusJson)}`); + logger.info(`In Initiate Promote Worker, projectStatusJson: ${JSON.stringify(projectStatusJson)}`); // write to JSONs to AIO Files for Projects Queue and Project Status await filesWrapper.writeFile('graybox_promote/project_queue.json', projectQueue); @@ -160,11 +160,11 @@ async function main(params) { // read Graybox Project Json from AIO Files const projectQueueJson = await filesWrapper.readFileIntoObject('graybox_promote/project_queue.json'); - logger.info(`Project Queue Json: ${JSON.stringify(projectQueueJson)}`); + logger.info(`In Initiate Promote Worker, Project Queue Json: ${JSON.stringify(projectQueueJson)}`); const statusJson = await filesWrapper.readFileIntoObject(`graybox_promote${gbRootFolder}/${experienceName}/status.json`); - logger.info(`Project Status Json: ${JSON.stringify(statusJson)}`); + logger.info(`In Initiate Promote Worker, Project Status Json: ${JSON.stringify(statusJson)}`); const projectBatchStatusJson = await filesWrapper.readFileIntoObject(`graybox_promote${gbRootFolder}/${experienceName}/batch_status.json`); - logger.info(`Project Batch Status Json: ${JSON.stringify(projectBatchStatusJson)}`); + logger.info(`In Initiate Promote Worker, Project Batch Status Json: ${JSON.stringify(projectBatchStatusJson)}`); // process data in batches let responsePayload; @@ -221,7 +221,6 @@ async function findAllGrayboxFiles({ for (let di = 0; di < driveItems?.length; di += 1) { const item = driveItems[di]; const itemPath = `${item.parentReference.path.replace(pPathRegExp, '')}/${item.name}`; - logger.info(`${itemPath} ::: ${pathsToSelectRegExp.test(itemPath)}`); if (!isFilePatternMatched(itemPath, promoteIgnoreList)) { if (item.folder) { // it is a folder diff --git a/actions/graybox/preview-worker.js b/actions/graybox/preview-worker.js index 973ca4d..3bdf075 100644 --- a/actions/graybox/preview-worker.js +++ b/actions/graybox/preview-worker.js @@ -46,6 +46,18 @@ async function main(params) { if (helixUtils.canBulkPreview(true)) { logger.info('In Preview Worker, Bulk Previewing Graybox files'); if ((projectStatusJson.status === 'initiated' || projectStatusJson.status === 'promoted')) { + try { + let excelValues = ''; + if (projectStatusJson.status === 'initiated') { + excelValues = [['Initial Preview of Graybox completed', toUTCStr(new Date()), `Initial Preview started for '${experienceName}' experience`]]; + } else if (projectStatusJson.status === 'promoted') { + excelValues = [['Final Preview of Promoted Content completed', toUTCStr(new Date()), `Final Preview started for promoted content of '${experienceName}' experience`]]; + } + // Update Preview Status + await sharepoint.updateExcelTable(projectExcelPath, 'PROMOTE_STATUS', excelValues); + } catch (err) { + logger.error(`Error Occured while updating Excel before starting Graybox Preview: ${err}`); + } const batchStatusJson = await filesWrapper.readFileIntoObject(`graybox_promote${gbRootFolder}/${experienceName}/batch_status.json`); logger.info(`In Preview-Worker, batchStatusJson: ${JSON.stringify(batchStatusJson)}`); @@ -135,7 +147,7 @@ async function main(params) { // Update Preview Status await sharepoint.updateExcelTable(projectExcelPath, 'PROMOTE_STATUS', excelValues); } catch (err) { - logger.error(`Error Occured while updating Excel during Graybox Initial Preview: ${err}`); + logger.error(`Error Occured while updating Excel during Graybox Preview: ${err}`); } } @@ -166,9 +178,11 @@ async function main(params) { const failedPreviewPaths = Object.keys(failedPreviewPathToBatchMap); + logger.info(`Failed paths from First Preview attempt ::: ${failedPreviewPaths}`); // Re-attempt preview for failed previews const reAttemptPreviewStatuses = await helixUtils.bulkPreview(failedPreviewPaths, helixUtils.getOperations().PREVIEW, experienceName, isGraybox); + logger.info(`Reattempt Preview Statuses :::: ${JSON.stringify(reAttemptPreviewStatuses)}`); // Update the previewStatuses object with the re-attempted preview statuses reAttemptPreviewStatuses.forEach((reattemptedStatus) => { // Extract the batch name for a specific path @@ -230,7 +244,6 @@ async function main(params) { if (batchJson) { batchJson.forEach((gbFile) => paths.push(handleExtension(gbFile))); - logger.info(`paths before initial preview :::: ${paths}`); // Perform Bulk Preview of a Batch of Graybox files if (isGraybox) { previewStatuses[batchName] = await helixUtils.bulkPreview(paths, helixUtils.getOperations().PREVIEW, experienceName, isGraybox);