Skip to content

Commit

Permalink
fix(cb2-10791): Archive technical records before creating new ones (p…
Browse files Browse the repository at this point in the history
…art of Remediate the ~1300 TRL Tech Records with a Primary VRM) (#110)
  • Loading branch information
me-matt authored Feb 22, 2024
1 parent 0d836b3 commit 55dec38
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/services/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ export const updateVehicle = async (recordsToArchive: TechRecordType<'get'>[], n

const transactWriteParams: TransactWriteCommandInput = { TransactItems: [] };

newRecords.forEach((record) => {
transactWriteParams.TransactItems?.push({
Put: {
TableName: tableName,
Item: marshall(record, { removeUndefinedValues: true }),
},
});
});

recordsToArchive.forEach((record) => {
transactWriteParams.TransactItems?.push(
{
Expand All @@ -178,6 +169,15 @@ export const updateVehicle = async (recordsToArchive: TechRecordType<'get'>[], n
);
});

newRecords.forEach((record) => {
transactWriteParams.TransactItems?.push({
Put: {
TableName: tableName,
Item: marshall(record, { removeUndefinedValues: true }),
},
});
});

const sendTransaction = new Promise<object>((resolve, reject) => {
ddbClient.send(new TransactWriteItemsCommand(transactWriteParams)).then(() => {
logger.debug('Resolving with success');
Expand Down

0 comments on commit 55dec38

Please sign in to comment.