Skip to content

Commit

Permalink
Fix category mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed May 13, 2024
1 parent 8f815a8 commit cc8ef06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/jobs/src/transactions/initial-sync.ts
Expand Up @@ -69,9 +69,9 @@ client.defineJob({
// NOTE: We will get all the transactions at once for each account so
// we need to guard against massive payloads
await processPromisesBatch(transactions, BATCH_LIMIT, async (batch) => {
const formatted = batch.map((transaction) => ({
...transaction,
category_slug: transaction.category,
const formatted = batch.map(({ category, ...rest }) => ({
...rest,
category_slug: category,
}));

await supabase.from("transactions").upsert(formatted, {
Expand Down
6 changes: 3 additions & 3 deletions packages/jobs/src/transactions/manual-sync.ts
Expand Up @@ -49,9 +49,9 @@ client.defineJob({
bankAccountId: account.id,
});

const formatted = transactions.map((transaction) => ({
...transaction,
category_slug: transaction.category,
const formatted = transactions.map(({ category, ...rest }) => ({
...rest,
category_slug: category,
}));

// NOTE: We will get all the transactions at once for each account so
Expand Down
6 changes: 3 additions & 3 deletions packages/jobs/src/transactions/sync.ts
Expand Up @@ -62,9 +62,9 @@ client.defineJob({
try {
if (promises) {
const result = await Promise.all(promises);
const transactions = result.flat()?.map((transaction) => ({
...transaction,
category_slug: transaction.category,
const transactions = result.flat()?.map(({ category, ...rest }) => ({
...rest,
category_slug: category,
}));

await io.logger.debug("Transactions", transactions);
Expand Down

0 comments on commit cc8ef06

Please sign in to comment.