From 022f3e2fd375a21ddad6edcf4a2aac1b95a089c9 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Fri, 8 Mar 2024 16:34:19 +0100 Subject: [PATCH] Debug --- packages/jobs/src/constants.ts | 2 +- .../jobs/src/transactions/notification.ts | 32 +++++++++---------- packages/jobs/src/transactions/sync.ts | 8 ++++- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/packages/jobs/src/constants.ts b/packages/jobs/src/constants.ts index 013fb597fc..3e365493da 100644 --- a/packages/jobs/src/constants.ts +++ b/packages/jobs/src/constants.ts @@ -2,7 +2,7 @@ export const Jobs = { TRANSACTIONS_EXPORT: "transactions-export", TRANSACTIONS_NOTIFICATION: "transactions-notification", TRANSACTION_SCHEDULER: "transaction-scheduler", - TRANSACTIONS_SYNC: "transactions-sync-v2", + TRANSACTIONS_SYNC: "transactions-sync", TRANSACTIONS_SETUP: "transactions-setup", PROCESS_DOCUMENT: "process-document", MATCH_INBOX: "match-inbox", diff --git a/packages/jobs/src/transactions/notification.ts b/packages/jobs/src/transactions/notification.ts index c0ff4d8e4e..f0eb63c779 100644 --- a/packages/jobs/src/transactions/notification.ts +++ b/packages/jobs/src/transactions/notification.ts @@ -66,17 +66,17 @@ client.defineJob({ })); }); - if (notificationPromises) { - const notificationEvents = await Promise.all(notificationPromises); + const notificationEvents = await Promise.all(notificationPromises); - if (notificationEvents?.length) { - triggerBulk(notificationEvents.flat()); - await io.logger.log( - `Sending notifications: ${notificationEvents.length}` - ); - } + if (notificationEvents?.length) { + triggerBulk(notificationEvents.flat()); + await io.logger.log( + `Sending notifications: ${notificationEvents.length}` + ); } + await io.logger.debug("notificationEvents", notificationEvents); + const emailPromises = usersData?.map(async ({ user, team_id }) => { const { t } = getI18n({ locale: user.locale }); @@ -104,15 +104,15 @@ client.defineJob({ }; }); - if (emailPromises) { - const emailEvents = await Promise.all(emailPromises); + const emailEvents = await Promise.all(emailPromises); + + await io.logger.debug("emailEvents", emailEvents); - if (emailEvents?.length) { - try { - triggerBulk(emailEvents.flat()); - } catch (error) { - await io.logger.debug(error); - } + if (emailEvents?.length) { + try { + triggerBulk(emailEvents.flat()); + } catch (error) { + await io.logger.debug(error); } } }, diff --git a/packages/jobs/src/transactions/sync.ts b/packages/jobs/src/transactions/sync.ts index 982c5a7e31..587f4ca91f 100644 --- a/packages/jobs/src/transactions/sync.ts +++ b/packages/jobs/src/transactions/sync.ts @@ -78,7 +78,13 @@ client.defineJob({ name: Events.TRANSACTIONS_NOTIFICATION, payload: { teamId, - transactions: transactionsData, + transactions: transactionsData.map((transaction) => ({ + id: transaction.id, + date: transaction.date, + amount: transaction.amount, + name: transaction.name, + currency: transaction.currency, + })), }, });