From bfb9b4920476cc700c9bd0763c325223fb226ad5 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sat, 22 Jul 2023 08:44:37 +0200 Subject: [PATCH] Clean up --- apps/api/src/app/account/account.service.ts | 10 ++-------- apps/api/src/app/portfolio/portfolio.service.ts | 13 +++---------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/apps/api/src/app/account/account.service.ts b/apps/api/src/app/account/account.service.ts index 2e1ce8a20..06a5dd250 100644 --- a/apps/api/src/app/account/account.service.ts +++ b/apps/api/src/app/account/account.service.ts @@ -52,7 +52,6 @@ export class AccountService { orderBy?: Prisma.AccountOrderByWithRelationInput; }): Promise< (Account & { - balances?: AccountBalance[]; Order?: Order[]; Platform?: Platform; })[] @@ -108,10 +107,7 @@ export class AccountService { public async getAccounts(aUserId: string) { const accounts = await this.accounts({ - include: { - Order: true, - Platform: true - }, + include: { Order: true, Platform: true }, orderBy: { name: 'asc' }, where: { userId: aUserId } }); @@ -170,9 +166,7 @@ export class AccountService { }; } - const accounts = await this.accounts({ - where - }); + const accounts = await this.accounts({ where }); for (const account of accounts) { totalCashBalanceInBaseCurrency = totalCashBalanceInBaseCurrency.plus( diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index c57121759..71267b91e 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -126,10 +126,7 @@ export class PortfolioService { const [accounts, details] = await Promise.all([ this.accountService.accounts({ where, - include: { - Order: true, - Platform: true - }, + include: { Order: true, Platform: true }, orderBy: { name: 'asc' } }), this.getDetails({ @@ -158,9 +155,8 @@ export class PortfolioService { ...account, transactionCount, valueInBaseCurrency, - balance: details.accounts[account.id].balance, balanceInBaseCurrency: this.exchangeRateDataService.toCurrency( - details.accounts[account.id].balance, + account.balance, account.currency, userCurrency ), @@ -1800,7 +1796,6 @@ export class PortfolioService { const platforms: PortfolioDetails['platforms'] = {}; let currentAccounts: (Account & { - balances?: AccountBalance[]; Order?: Order[]; Platform?: Platform; })[] = []; @@ -1809,9 +1804,7 @@ export class PortfolioService { currentAccounts = await this.accountService.getAccounts(userId); } else if (filters.length === 1 && filters[0].type === 'ACCOUNT') { currentAccounts = await this.accountService.accounts({ - include: { - Platform: true - }, + include: { Platform: true }, where: { id: filters[0].id } }); } else {