Skip to content

Commit 90e295d

Browse files
Merge pull request #289 from aws-samples/cross-runtime-fixes
fix: cross-runtime consistency fixes
2 parents 27584de + 4a5c717 commit 90e295d

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

unicorn_contracts/src/contracts_service/contractEventHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ContractEventHandlerFunction implements LambdaInterface {
165165
const ddbUpdateCommandInput: UpdateItemCommandInput = {
166166
TableName: DDB_TABLE,
167167
Key: { property_id: { S: dbEntry.property_id } },
168-
UpdateExpression: 'set contract_status = :t, modified_date = :m',
168+
UpdateExpression: 'set contract_status = :t, contract_last_modified_on = :m',
169169
ConditionExpression:
170170
'attribute_exists(property_id) AND contract_status = :DRAFT',
171171
ExpressionAttributeValues: {

unicorn_web/src/publication_manager_service/publicationEvaluationEventHandler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PublicationEvaluationEventHandler implements LambdaInterface {
4343
tracer.addErrorAsMetadata(error as Error);
4444
logger.error(`Error during DDB UPDATE: ${JSON.stringify(error)}`);
4545
}
46-
metrics.addMetric('ContractUpdated', MetricUnit.Count, 1);
46+
metrics.addMetric('PropertiesApproved', MetricUnit.Count, 1);
4747
}
4848

4949
/**
@@ -63,6 +63,11 @@ class PublicationEvaluationEventHandler implements LambdaInterface {
6363
`Updating status: ${propertyEvaluation.evaluationResult} for ${propertyEvaluation.propertyId}`
6464
);
6565
const propertyId = propertyEvaluation.propertyId;
66+
const validResults = ['APPROVED', 'DECLINED'];
67+
if (!validResults.includes(propertyEvaluation.evaluationResult?.toUpperCase())) {
68+
logger.warn(`Unknown evaluationResult '${propertyEvaluation.evaluationResult}'; skipping DynamoDB update`);
69+
return;
70+
}
6671
const { PK, SK } = this.getDynamoDBKeys(propertyId);
6772
const updateItemCommandInput: UpdateItemCommandInput = {
6873
Key: { PK: { S: PK }, SK: { S: SK } },

unicorn_web/src/publication_manager_service/requestApprovalFunction.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class RequestApprovalFunction implements LambdaInterface {
140140
description: property.description,
141141
};
142142

143-
await this.firePropertyEvent(eventDetail, 'unicorn-web');
143+
await this.firePropertyEvent(eventDetail);
144144
} catch (error) {
145145
tracer.addErrorAsMetadata(error as Error);
146146
logger.error(`${error}`);
@@ -181,16 +181,15 @@ class RequestApprovalFunction implements LambdaInterface {
181181
* @param source
182182
*/
183183
private async firePropertyEvent(
184-
eventDetail: PropertyDetailsEvent,
185-
source: string
184+
eventDetail: PropertyDetailsEvent
186185
): Promise<void> {
187186
const propertyId = eventDetail.property_id;
188187

189188
// Build the Command objects
190189
const eventsPutEventsCommandInputEntry: PutEventsRequestEntry = {
191190
EventBusName: EVENT_BUS,
192191
Time: new Date(),
193-
Source: source,
192+
Source: process.env.SERVICE_NAMESPACE ?? 'unicorn-web',
194193
DetailType: 'PublicationApprovalRequested',
195194
Detail: JSON.stringify(eventDetail),
196195
};

unicorn_web/src/search_service/propertySearchFunction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ class PropertySearchFunction implements LambdaInterface {
205205
const city = event.pathParameters?.city;
206206
const street = event.pathParameters?.street;
207207
const number = event.pathParameters?.number;
208-
console.log(`Country: ${country}`);
209-
console.log(`City: ${city}`);
210-
console.log(`street: ${street}`);
211-
console.log(`number: ${number}`);
212-
console.log(`PROJECT PROPS: ${PROJECTION_PROPERTIES}`);
208+
logger.info(`Country: ${country}`);
209+
logger.info(`City: ${city}`);
210+
logger.info(`street: ${street}`);
211+
logger.info(`number: ${number}`);
212+
logger.info(`PROJECT PROPS: ${PROJECTION_PROPERTIES}`);
213213

214214
logger.info(
215215
`Get property details for: country = ${country}; city = ${city}; street = ${street}; number = ${number}`

0 commit comments

Comments
 (0)