Skip to content

Commit

Permalink
203 Update prefixing of orc numbers when doing local lookups. (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklise authored Nov 1, 2023
1 parent 503974c commit 30cb30c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __tests__/name-update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function setupDb() {
"legacy_backcountryCabinsNetRevenue": 0,
"legacy_backcountryCabinsTotalAttendancePeople": 0
},
"orcs": "1",
"orcs": "0001",
"parkName": "Strathcona Park",
"subAreaId": "0673"
}
Expand Down
14 changes: 8 additions & 6 deletions lambda/nameUpdate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 30cb30c

Please sign in to comment.