Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Nov 22, 2024
1 parent a3f33f7 commit debad53
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/tasks/sync-registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ const processJob = async () => {
}
};

async function updateAuditTransaction(callback, afterCommitCallbacks) {
let result = null;

async function createAndProcessTransaction(callback, afterCommitCallbacks) {
let transaction;
let mirrorTransaction;

Expand All @@ -158,7 +156,7 @@ async function updateAuditTransaction(callback, afterCommitCallbacks) {
}

// Execute the provided callback with the transaction
result = await callback(transaction, mirrorTransaction);
await callback(transaction, mirrorTransaction);

// Commit the transaction if the callback completes without errors
await transaction.commit();
Expand All @@ -173,14 +171,15 @@ async function updateAuditTransaction(callback, afterCommitCallbacks) {

logger.info('Commited sequelize transaction');

return result;
return true;
} catch (error) {
// Roll back the transaction if an error occurs
if (transaction) {
logger.error(
`encountered error syncing organization audit. Rolling back transaction. Error: ${error}`,
);
await transaction.rollback();
return false;
}
} finally {
releaseTransactionMutex();
Expand Down Expand Up @@ -486,10 +485,7 @@ const syncOrganizationAudit = async (organization) => {
// by not processing the DELETE for that record.
const optimizedKvDiff = optimizeAndSortKvDiff(kvDiff);

const createAndProcessTransaction = async (
transaction,
mirrorTransaction,
) => {
const updateAuditTransaction = async (transaction, mirrorTransaction) => {
logger.info(
`Syncing ${organization.name} generation ${toBeProcessedDatalayerGenerationIndex} (orgUid ${organization.orgUid}, registryId ${organization.registryId})`,
);
Expand Down

0 comments on commit debad53

Please sign in to comment.