From 55ce72d0113e950f5f02d66f71d478a5721cd549 Mon Sep 17 00:00:00 2001 From: cameron Date: Thu, 10 Oct 2024 21:34:18 +0000 Subject: [PATCH] update protected area data to include place prefix --- handlers/protectedAreas/PUT/index.js | 2 +- handlers/protectedAreas/_orcs/PUT/index.js | 2 +- handlers/synchronization/syncCMSProtectedAreas/index.js | 2 +- handlers/synchronization/syncDataRegister/index.js | 6 +++--- layers/dataUtils/protectedAreas/methods.js | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/handlers/protectedAreas/PUT/index.js b/handlers/protectedAreas/PUT/index.js index 75d571d..7bba4d8 100644 --- a/handlers/protectedAreas/PUT/index.js +++ b/handlers/protectedAreas/PUT/index.js @@ -26,7 +26,7 @@ exports.handler = async (event, context) => { delete item.orcs; const updateItem = { - key: { pk: 'protectedArea', sk: sk }, + key: { pk: 'place::protectedArea', sk: sk }, data: item, }; diff --git a/handlers/protectedAreas/_orcs/PUT/index.js b/handlers/protectedAreas/_orcs/PUT/index.js index 65cb9b2..f0390ba 100644 --- a/handlers/protectedAreas/_orcs/PUT/index.js +++ b/handlers/protectedAreas/_orcs/PUT/index.js @@ -17,7 +17,7 @@ exports.handler = async (event, context) => { // Format body with key const updateItem = { - key: { pk: 'protectedArea', sk: orcs }, + key: { pk: 'place::protectedArea', sk: orcs }, data: body, }; diff --git a/handlers/synchronization/syncCMSProtectedAreas/index.js b/handlers/synchronization/syncCMSProtectedAreas/index.js index e28d888..7614a95 100644 --- a/handlers/synchronization/syncCMSProtectedAreas/index.js +++ b/handlers/synchronization/syncCMSProtectedAreas/index.js @@ -46,7 +46,7 @@ exports.handler = async (event, context) => { const fieldsToSync = getFieldsToSync(res.data); const updateItem = { key: { - pk: 'protectedArea', + pk: 'place::protectedArea', sk: protectedArea.orcs }, set: fieldsToSync diff --git a/handlers/synchronization/syncDataRegister/index.js b/handlers/synchronization/syncDataRegister/index.js index fd08989..21b139a 100644 --- a/handlers/synchronization/syncDataRegister/index.js +++ b/handlers/synchronization/syncDataRegister/index.js @@ -58,7 +58,7 @@ async function syncData(protectedAreas) { // DynamoDB RRUs are 20% the cost of WRUs, so we can afford to check if the item exists before // adding it, instead of doing a PUT with a conditional expression. // Usually this should be cheaper since we expect most items to already exist. - const existingItem = await getOne('protectedArea', protectedArea.pk); + const existingItem = await getOne('place::protectedArea', protectedArea.pk); // If the item does not exist, add it to the database if (!existingItem) { @@ -81,7 +81,7 @@ async function syncData(protectedAreas) { async function createPutPAItem(protectedArea, timestamp) { let item = { - pk: 'protectedArea', + pk: 'place::protectedArea', sk: protectedArea.pk, orcs: protectedArea.pk, creationDate: timestamp, @@ -118,7 +118,7 @@ function createUpdatePAItem(protectedArea, timestamp) { data: { TableName: TABLE_NAME, Key: { - pk: { S: 'protectedArea' }, + pk: { S: 'place::protectedArea' }, sk: { S: protectedArea.pk } }, UpdateExpression: updateExpression, diff --git a/layers/dataUtils/protectedAreas/methods.js b/layers/dataUtils/protectedAreas/methods.js index 41b7b5f..d0222d1 100644 --- a/layers/dataUtils/protectedAreas/methods.js +++ b/layers/dataUtils/protectedAreas/methods.js @@ -27,7 +27,7 @@ async function getProtectedAreas(params) { TableName: TABLE_NAME, KeyConditionExpression: 'pk = :pk', ExpressionAttributeValues: { - ':pk': { S: 'protectedArea' }, + ':pk': { S: 'place::protectedArea' }, }, }; const res = await runQuery(queryObj, limit, lastEvaluatedKey, paginated); @@ -47,7 +47,7 @@ async function getProtectedAreas(params) { */ async function getProtectedAreaByOrcs(orcs) { try { - const res = await getOne('protectedArea', orcs); + const res = await getOne('place::protectedArea', orcs); return res; } catch (error) { throw new Exception('Error getting protected area', { code: 400, error: error });