Skip to content

Commit

Permalink
update protected area data to include place prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronpettit committed Oct 10, 2024
1 parent c011315 commit 55ce72d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion handlers/protectedAreas/PUT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion handlers/protectedAreas/_orcs/PUT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion handlers/synchronization/syncCMSProtectedAreas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions handlers/synchronization/syncDataRegister/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions layers/dataUtils/protectedAreas/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 });
Expand Down

0 comments on commit 55ce72d

Please sign in to comment.