Skip to content

Commit

Permalink
disable event does not affect status
Browse files Browse the repository at this point in the history
  • Loading branch information
kristin-at-theta committed Sep 20, 2023
1 parent a67c51f commit 8fbbdb3
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 697 deletions.
15 changes: 8 additions & 7 deletions services/app-api/form/disableRaiWithdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ async function waitForStreamProcessing(componentId, eventTimestamp) {
do {
await new Promise((resolve) => setTimeout(resolve, 1000));
const chkResponse = await dynamoDb.get(checkParams);
packageUpdated = chkResponse?.Item?.lastEventTimestamp >= eventTimestamp;
packageUpdated =
chkResponse?.Item?.adminChanges[0]?.changeTimestamp >= eventTimestamp;
} while (!packageUpdated);
} catch (e) {
console.log("%s check error:", componentId, e);
Expand Down Expand Up @@ -139,20 +140,20 @@ export const main = handler(async (event) => {
// the first record is the most recent as they were sorted by submissionTimestamp
const mostRecentRecord = records[0];
mostRecentRecord.currentStatus = Workflow.ONEMAC_STATUS.SUBMITTED;
mostRecentRecord.eventTimestamp = Date.now();
// set the eventTimestamp back to submissionTimestamp so that the
// status is set correctly
mostRecentRecord.eventTimestamp = data.submissionTimestamp;
const checkTimestamp = Date.now();
const adminChange = {
changeTimestamp: mostRecentRecord.eventTimestamp,
changeTimestamp: checkTimestamp,
changeMade: `${data.submitterName} has disabled State package action to withdraw Formal RAI Response`,
changeReason: data.additionalInformation,
};
mostRecentRecord.adminChanges = mostRecentRecord.adminChanges
? [...mostRecentRecord.adminChanges, adminChange]
: [adminChange];
await updateRecord(mostRecentRecord);
await waitForStreamProcessing(
data.componentId,
mostRecentRecord.eventTimestamp
);
await waitForStreamProcessing(data.componentId, checkTimestamp);
} else {
throw new Error(
"No RAI found when attempting to enable rai withdraw for ",
Expand Down
Loading

0 comments on commit 8fbbdb3

Please sign in to comment.