From a962adcf9e5524aed73cc9faafc4199c1c6f0afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Sander?= Date: Wed, 20 Mar 2024 20:41:10 +0000 Subject: [PATCH] fix(qseow): Show regular sheet ids instead of engine sheet ids in log output Fixes #529 --- src/lib/qseow/qseow-create-thumbnails.js | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/lib/qseow/qseow-create-thumbnails.js b/src/lib/qseow/qseow-create-thumbnails.js index 572b4fe8..e72070e3 100644 --- a/src/lib/qseow/qseow-create-thumbnails.js +++ b/src/lib/qseow/qseow-create-thumbnails.js @@ -125,7 +125,7 @@ const processQSEoWApp = async (appId, g, options) => { let appMetadata = await qrsInteractInstance.Get(`app?filter=id eq ${appId}`); appMetadata = appMetadata.body; - // Get app objet metadata + // Get metadata for the app sheets that should be excluded based on sheet tags logger.debug( `GET tagExcludeSheetAppMetadata: app/object/full?filter=objectType eq 'sheet' and app.id eq ${appId} and tags.name eq '${options.excludeSheetTag}'` ); @@ -134,6 +134,20 @@ const processQSEoWApp = async (appId, g, options) => { ); tagExcludeSheetAppMetadata = tagExcludeSheetAppMetadata.body; + // Create mapping between repo db sheet id and engine sheet id + let mapRepoEngineSheetIdTmp1 = await qrsInteractInstance.Get( + `app/object/full?filter=objectType eq 'sheet' and app.id eq ${appId}` + ); + mapRepoEngineSheetIdTmp1 = mapRepoEngineSheetIdTmp1.body; + + // mapRepoEngineSheetIdTmp1 is an array of sheet objects, each object has properties called 'id' and 'engineObjectId' + // Create a new bidirectional map between repo db sheet id and engine sheet id + const mapRepoEngineSheetId = new Map(); + mapRepoEngineSheetIdTmp1.forEach((element) => { + mapRepoEngineSheetId.set(element.id, element.engineObjectId); + mapRepoEngineSheetId.set(element.engineObjectId, element.id); + }); + // Configure Enigma.js const configEnigma = setupEnigmaConnection(appId, options); const imgDir = options.imagedir; @@ -345,6 +359,10 @@ const processQSEoWApp = async (appId, g, options) => { // Loop over all sheets in app // eslint-disable-next-line no-restricted-syntax for (const sheet of sheetListObj.qAppObjectList.qItems) { + // Get repository db sheet id from mapRepoEngineSheetIdTmp1, using sheet.qInfo.qId as key + const repoDbSheetId = mapRepoEngineSheetId.get(sheet.qInfo.qId); + const engineSheetId = sheet.qInfo.qId; + // Should this sheet be processed, or is it on exclude list? // Options are // --exclude-sheet-tag @@ -364,7 +382,7 @@ const processQSEoWApp = async (appId, g, options) => { ) { excludeSheet = true; logger.verbose( - `Excluded sheet (status public): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` + `Excluded sheet (status public): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` ); } @@ -377,7 +395,7 @@ const processQSEoWApp = async (appId, g, options) => { ) { excludeSheet = true; logger.verbose( - `Excluded sheet (status published): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` + `Excluded sheet (status published): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` ); } @@ -390,7 +408,7 @@ const processQSEoWApp = async (appId, g, options) => { ) { excludeSheet = true; logger.verbose( - `Excluded sheet (status private): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` + `Excluded sheet (status private): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved ${sheet.qMeta.approved}, published ${sheet.qMeta.published}` ); } @@ -414,7 +432,7 @@ const processQSEoWApp = async (appId, g, options) => { if (sheetIsHidden === true && excludeSheet === false) { excludeSheet = true; logger.verbose( - `Excluded sheet (hidden): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` + `Excluded sheet (hidden): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` ); } @@ -436,7 +454,7 @@ const processQSEoWApp = async (appId, g, options) => { if (options.excludeSheetNumber.includes(iSheetNum.toString())) { excludeSheet = true; logger.verbose( - `Excluded sheet (via sheet number): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` + `Excluded sheet (via sheet number): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` ); } } @@ -448,18 +466,18 @@ const processQSEoWApp = async (appId, g, options) => { excludeSheet = true; logger.verbose( - `Excluded sheet (via sheet title): ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` + `Excluded sheet (via sheet title): ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` ); } } if (excludeSheet === true) { logger.info( - `Excluded sheet: ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` + `Excluded sheet: ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` ); } else { logger.info( - `Processing sheet ${iSheetNum}: '${sheet.qMeta.title}', ID ${sheet.qInfo.qId}, description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` + `Processing sheet ${iSheetNum}: '${sheet.qMeta.title}', sheet id '${repoDbSheetId}', engine sheet id '${engineSheetId}', description '${sheet.qMeta.description}', approved '${sheet.qMeta.approved}', published '${sheet.qMeta.published}', hidden '${sheetIsHidden}'` ); // Build URL to current sheet const sheetUrl = `${appUrl}/sheet/${sheet.qInfo.qId}`;