Skip to content

Commit

Permalink
#1738: skip re-retrieve if all publish actions failed
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Sep 26, 2024
1 parent a10addb commit d3e9479
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -1856,41 +1856,44 @@ class Journey extends MetadataType {
}).start();
const transactionalKeyArr = (await Promise.all(resultsTransactional)).filter(Boolean);
spinner.success('done.');
executedKeyArr.push(...transactionalKeyArr);

Util.logger.info('Retrieving relevant journeys');
const retriever = new Retriever(this.properties, this.buObject);
// if all publish actions failed, we don't need to re-retrieve anything here
if (transactionalKeyArr.length) {
executedKeyArr.push(...transactionalKeyArr);

try {
const updatedJourneyRetrieve = await retriever.retrieve(
['journey'],
transactionalKeyArr
);
Util.logger.info('Retrieving relevant journeys');
const retriever = new Retriever(this.properties, this.buObject);

/** @type {MetadataTypeItem[]} */
const updatedJourneys = Object.values(updatedJourneyRetrieve?.journey[0]);
if (updatedJourneys) {
const updatedTransactionalEmails = [];
for (const journey of updatedJourneys) {
updatedTransactionalEmails.push(
journey.activities?.[0]?.configurationArguments
?.r__transactionalEmail_key
);
}
if (updatedTransactionalEmails.filter(Boolean).length) {
Util.logger.info('Retrieving relevant transactionalEmails');
await retriever.retrieve(
['transactionalEmail'],
updatedTransactionalEmails.filter(Boolean)
);
} else {
Util.logger.error(
`Could not find transactional Emails for the published journeys`
);
try {
const updatedJourneyRetrieve = await retriever.retrieve(
['journey'],
transactionalKeyArr
);
/** @type {MetadataTypeItem[]} */
const updatedJourneys = Object.values(updatedJourneyRetrieve?.journey[0]);
if (updatedJourneys) {
const updatedTransactionalEmails = [];
for (const journey of updatedJourneys) {
updatedTransactionalEmails.push(
journey.activities?.[0]?.configurationArguments
?.r__transactionalEmail_key
);
}
if (updatedTransactionalEmails.filter(Boolean).length) {
Util.logger.info('Retrieving relevant transactionalEmails');
await retriever.retrieve(
['transactionalEmail'],
updatedTransactionalEmails.filter(Boolean)
);
} else {
Util.logger.error(
`Could not find transactional Emails for the published journeys`
);
}
}
} catch (ex) {
Util.logger.errorStack(ex, 'retrieve failed');
}
} catch (ex) {
Util.logger.errorStack(ex, 'retrieve failed');
}
}
Util.logger.info(
Expand Down

0 comments on commit d3e9479

Please sign in to comment.