Browse Source

Refactoring

pull/3764/head
Thomas Kaul 12 months ago
parent
commit
8b478af329
  1. 26
      apps/api/src/app/portfolio/portfolio.service.ts

26
apps/api/src/app/portfolio/portfolio.service.ts

@ -115,35 +115,35 @@ export class PortfolioService {
}): Promise<AccountWithValue[]> { }): Promise<AccountWithValue[]> {
const where: Prisma.AccountWhereInput = { userId }; const where: Prisma.AccountWhereInput = { userId };
const accountFilter = filters?.find(({ type }) => { const filterByAccount = filters?.find(({ type }) => {
return type === 'ACCOUNT'; return type === 'ACCOUNT';
}); })?.id;
const dataSourceFilter = filters?.find(({ type }) => { const filterByDataSource = filters?.find(({ type }) => {
return type === 'DATA_SOURCE'; return type === 'DATA_SOURCE';
}); })?.id;
const symbolFilter = filters?.find(({ type }) => { const filterBySymbol = filters?.find(({ type }) => {
return type === 'SYMBOL'; return type === 'SYMBOL';
}); })?.id;
if (filterByAccount) {
where.id = filterByAccount;
}
if (dataSourceFilter && symbolFilter) { if (filterByDataSource && filterBySymbol) {
where.Order = { where.Order = {
some: { some: {
SymbolProfile: { SymbolProfile: {
AND: [ AND: [
{ dataSource: <DataSource>dataSourceFilter.id }, { dataSource: <DataSource>filterByDataSource },
{ symbol: symbolFilter.id } { symbol: filterBySymbol }
] ]
} }
} }
}; };
} }
if (accountFilter) {
where.id = accountFilter.id;
}
const [accounts, details] = await Promise.all([ const [accounts, details] = await Promise.all([
this.accountService.accounts({ this.accountService.accounts({
where, where,

Loading…
Cancel
Save