Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ContractEventHandlerFunction implements LambdaInterface {
const ddbUpdateCommandInput: UpdateItemCommandInput = {
TableName: DDB_TABLE,
Key: { property_id: { S: dbEntry.property_id } },
UpdateExpression: 'set contract_status = :t, modified_date = :m',
UpdateExpression: 'set contract_status = :t, contract_last_modified_on = :m',
ConditionExpression:
'attribute_exists(property_id) AND contract_status = :DRAFT',
ExpressionAttributeValues: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PublicationEvaluationEventHandler implements LambdaInterface {
tracer.addErrorAsMetadata(error as Error);
logger.error(`Error during DDB UPDATE: ${JSON.stringify(error)}`);
}
metrics.addMetric('ContractUpdated', MetricUnit.Count, 1);
metrics.addMetric('PropertiesApproved', MetricUnit.Count, 1);
}

/**
Expand All @@ -63,6 +63,11 @@ class PublicationEvaluationEventHandler implements LambdaInterface {
`Updating status: ${propertyEvaluation.evaluationResult} for ${propertyEvaluation.propertyId}`
);
const propertyId = propertyEvaluation.propertyId;
const validResults = ['APPROVED', 'DECLINED'];
if (!validResults.includes(propertyEvaluation.evaluationResult?.toUpperCase())) {
logger.warn(`Unknown evaluationResult '${propertyEvaluation.evaluationResult}'; skipping DynamoDB update`);
return;
}
const { PK, SK } = this.getDynamoDBKeys(propertyId);
const updateItemCommandInput: UpdateItemCommandInput = {
Key: { PK: { S: PK }, SK: { S: SK } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class RequestApprovalFunction implements LambdaInterface {
description: property.description,
};

await this.firePropertyEvent(eventDetail, 'unicorn-web');
await this.firePropertyEvent(eventDetail);
} catch (error) {
tracer.addErrorAsMetadata(error as Error);
logger.error(`${error}`);
Expand Down Expand Up @@ -181,16 +181,15 @@ class RequestApprovalFunction implements LambdaInterface {
* @param source
*/
private async firePropertyEvent(
eventDetail: PropertyDetailsEvent,
source: string
eventDetail: PropertyDetailsEvent
): Promise<void> {
const propertyId = eventDetail.property_id;

// Build the Command objects
const eventsPutEventsCommandInputEntry: PutEventsRequestEntry = {
EventBusName: EVENT_BUS,
Time: new Date(),
Source: source,
Source: process.env.SERVICE_NAMESPACE ?? 'unicorn-web',
DetailType: 'PublicationApprovalRequested',
Detail: JSON.stringify(eventDetail),
};
Expand Down
10 changes: 5 additions & 5 deletions unicorn_web/src/search_service/propertySearchFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ class PropertySearchFunction implements LambdaInterface {
const city = event.pathParameters?.city;
const street = event.pathParameters?.street;
const number = event.pathParameters?.number;
console.log(`Country: ${country}`);
console.log(`City: ${city}`);
console.log(`street: ${street}`);
console.log(`number: ${number}`);
console.log(`PROJECT PROPS: ${PROJECTION_PROPERTIES}`);
logger.info(`Country: ${country}`);
logger.info(`City: ${city}`);
logger.info(`street: ${street}`);
logger.info(`number: ${number}`);
logger.info(`PROJECT PROPS: ${PROJECTION_PROPERTIES}`);

logger.info(
`Get property details for: country = ${country}; city = ${city}; street = ${street}; number = ${number}`
Expand Down
Loading