Skip to content

Commit

Permalink
Merge pull request #254 from aws-samples/fix/job-status-duplicate
Browse files Browse the repository at this point in the history
Fix/job status duplicate
  • Loading branch information
kishd authored Mar 29, 2024
2 parents b09228a + acabaaf commit 0c1b376
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Fix an issue with job status indicator (step function workflow) inserting duplicate entries into DynamoDB.

## [0.7.7] - 2024-03-06
### Added
- Fix #245 TranscriptKendraSearch page fails to build / load after deployment
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.7
0.7.7
2 changes: 1 addition & 1 deletion pca-ui/cfn/lib/deploy.template
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Resources:
Properties:
ServiceToken: !GetAtt DeployFunction.Arn
Counter: !Ref DeployCountValue
Version: "0.7.6"
Version: "0.7.8"

Configure:
Type: "AWS::CloudFormation::CustomResource"
Expand Down
1 change: 1 addition & 0 deletions pca-ui/src/lambda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async function createRecord(record) {
agent: parsed.ConversationAnalytics.Agent,
customer: parsed.ConversationAnalytics.Cust,
guid: parsed.ConversationAnalytics.GUID,
status: "Done",
};


Expand Down
15 changes: 12 additions & 3 deletions pca-ui/src/lambda/input_bucket_trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ exports.handler = async function (event, context) {
console.log(input);
const jobName = getJobNameFromKey(input.key);
const outputFileName = getFilenameFromKey(input.key);
const promise = createRecord(outputFileName, jobName, outputState);
return await Promise.all([promise]);


// The Done/Success state corresponds to when pca-aws-sf-post-processing function
// completes successfully. It writes the final results to the output (results) S3 bucket.
// The S3 bucket has a trigger that finally updates the DynamoDB table with call summary
// and other information. This creates a race condition and can cause a "stale" Done record
// to be written to the DynamoDB table. Handle updating the status to Done in the output
// S3 bucket trigger.

if (outputState !== "Done") {
const promise = createRecord(outputFileName, jobName, outputState);
return await Promise.all([promise]);
}
} else if(eventType === "Object Created") {
// this is most likely the s3 end drop trigger
const eventObjectKey = event.detail.object.key;
Expand Down
4 changes: 2 additions & 2 deletions pca-ui/src/www/src/components/ContactTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const COLUMN_DEFINITIONS = [
header: "Timestamp",
sortingField: "timestamp",
cell: (d) => {
if(d.status !== undefined && d.status.length > 0) {
if(d.status !== undefined && d.status.length > 0 && d.status !== "Done") {
return (
Formatter.Timestamp(d.timestamp)
)
Expand All @@ -40,7 +40,7 @@ const COLUMN_DEFINITIONS = [
id: "jobName",
header: "Job Name",
cell: (d) => {
if(d.status !== undefined && d.status.length > 0) {
if(d.status !== undefined && d.status.length > 0 && d.status !== "Done") {
return (
d.jobName
)
Expand Down

0 comments on commit 0c1b376

Please sign in to comment.