Skip to content

Commit

Permalink
Sorted transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 3, 2024
1 parent dadf3b5 commit e51020f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
12 changes: 8 additions & 4 deletions apps/dashboard/jobs/tasks/bank/notifications/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ export const transactionNotifications = schemaTask({
.eq("role", "owner")
.throwOnError();

if (transactionsData && transactionsData.length > 0) {
await handleTransactionNotifications(usersData, transactionsData);
await handleTransactionEmails(usersData, transactionsData);
await handleTransactionSlackNotifications(teamId, transactionsData);
const sortedTransactions = transactionsData?.sort((a, b) => {
return new Date(b.date).getTime() - new Date(a.date).getTime();
});

if (sortedTransactions && sortedTransactions.length > 0) {
await handleTransactionNotifications(usersData, sortedTransactions);
await handleTransactionEmails(usersData, sortedTransactions);
await handleTransactionSlackNotifications(teamId, sortedTransactions);
}
} catch (error) {
await logger.error("Transactions notification", { error });
Expand Down
3 changes: 0 additions & 3 deletions apps/dashboard/jobs/tasks/bank/sync/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ export const syncConnection = schemaTask({
.from("bank_connections")
.update({ status: "disconnected" })
.eq("id", connectionId);

// Revalidate the bank cache (transactions, accounts, connections)
await revalidateCache({ tag: "bank", teamId: data.team_id });
}
} catch (error) {
logger.error("Failed to sync connection", { error });
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/jobs/utils/transaction-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export async function handleTransactionNotifications(
name: TriggerEvents.TransactionsNewInApp,
payload: {
type: NotificationTypes.Transactions,
from: transactions[0]?.date,
to: transactions[transactions.length - 1]?.date,
from: transactions[transactions.length - 1]?.date,
to: transactions[0]?.date,
description: t("notifications.transactions", {
numberOfTransactions: transactions.length,
// For single transaction
Expand Down
2 changes: 1 addition & 1 deletion packages/email/emails/transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export const TransactionsEmail = ({
<Section className="text-center mt-[32px] mb-[32px]">
<Button
className="bg-transparent text-primary text-[14px] text-[#121212] font-medium no-underline text-center px-6 py-3 border border-solid border-[#121212]"
href={`${baseAppUrl}/transactions?start=${transactions.at(0)?.date}&end=${transactions[transactions.length - 1]?.date}`}
href={`${baseAppUrl}/transactions?start=${transactions[transactions.length - 1]?.date}&end=${transactions.at(0)?.date}`}
>
{t("transactions.button")}
</Button>
Expand Down

0 comments on commit e51020f

Please sign in to comment.