From c5e2e7b84af5287da5bdf6f3cbcc75c6fbfae68f Mon Sep 17 00:00:00 2001 From: Adrian Smijulj Date: Wed, 21 Aug 2024 20:57:40 +0200 Subject: [PATCH] fix:do not skip adding of published record to `ddbEsItemsToBatchRead (#4234) --- .../migrations/5.39.6/001/ddb-es/worker.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/migrations/src/migrations/5.39.6/001/ddb-es/worker.ts b/packages/migrations/src/migrations/5.39.6/001/ddb-es/worker.ts index 408ef414b62..12503ebc867 100644 --- a/packages/migrations/src/migrations/5.39.6/001/ddb-es/worker.ts +++ b/packages/migrations/src/migrations/5.39.6/001/ddb-es/worker.ts @@ -278,21 +278,22 @@ if (process.env.WEBINY_MIGRATION_5_39_6_001_BATCH_WRITE_MAX_CHUNK) { */ const ddbEsLatestRecordKey = `${item.entryId}:L`; - if (ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) { - continue; + if (!ddbEsItemsToBatchRead[ddbEsLatestRecordKey]) { + ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({ + PK: item.PK, + SK: "L" + }); } - ddbEsItemsToBatchRead[ddbEsLatestRecordKey] = ddbEsEntryEntity.getBatch({ - PK: item.PK, - SK: "L" - }); - const ddbEsPublishedRecordKey = `${item.entryId}:P`; - if (item.status === "published" || !!item.locked) { - ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = ddbEsEntryEntity.getBatch({ - PK: item.PK, - SK: "P" - }); + if (!ddbEsItemsToBatchRead[ddbEsPublishedRecordKey]) { + if (item.status === "published" || !!item.locked) { + ddbEsItemsToBatchRead[ddbEsPublishedRecordKey] = + ddbEsEntryEntity.getBatch({ + PK: item.PK, + SK: "P" + }); + } } }