From 30cb30c6b5d58bb376f298e6fd1832297b92d0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Lis=C3=A9?= Date: Wed, 1 Nov 2023 15:37:59 -0700 Subject: [PATCH] 203 Update prefixing of orc numbers when doing local lookups. (#274) --- __tests__/name-update.test.js | 2 +- lambda/nameUpdate/index.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/__tests__/name-update.test.js b/__tests__/name-update.test.js index 8879eaf..fde4a5f 100644 --- a/__tests__/name-update.test.js +++ b/__tests__/name-update.test.js @@ -23,7 +23,7 @@ async function setupDb() { "legacy_backcountryCabinsNetRevenue": 0, "legacy_backcountryCabinsTotalAttendancePeople": 0 }, - "orcs": "1", + "orcs": "0001", "parkName": "Strathcona Park", "subAreaId": "0673" } diff --git a/lambda/nameUpdate/index.js b/lambda/nameUpdate/index.js index f45785c..eade1e6 100644 --- a/lambda/nameUpdate/index.js +++ b/lambda/nameUpdate/index.js @@ -135,15 +135,17 @@ async function updateAllRecords(records) { }; for(const record of records) { logger.info("----------------------"); - logger.debug(record); + logger.debug(JSON.stringify(record)); updateObj.ExpressionAttributeValues[':parkName'].S = record.displayName; - // Each record is a seperate protected area in the data register - logger.info(`Getting indexed record set for:${record.pk}`); - const recordsToUpdate = await getIndexedRecordSet(record.pk); - logger.debug(recordsToUpdate); + // Each record is a seperate protected area in the data register. The difference currently with + // A&R is that there are 0 prefixes on numbers in 4 digits. + const pk = String(record.pk).padStart(4, '0'); + logger.info(`Getting indexed record set for:${pk}`); + const recordsToUpdate = await getIndexedRecordSet(pk); + logger.debug(JSON.stringify(recordsToUpdate)); logger.info(`Size: ${recordsToUpdate.length}`); if (recordsToUpdate.length > 0) { - process.stdout.write(`Orcs: ${record.pk} (${recordsToUpdate.length} records)`); + process.stdout.write(`Orcs: ${pk} (${recordsToUpdate.length} records)`); // Update all the records await updateRecords(recordsToUpdate, updateObj); }