Browse Source

First try adding tag to portfolio performance analysis

pull/5027/head
Dan 2 years ago
parent
commit
a6880e1aff
  1. 35
      apps/api/src/app/order/order.service.ts
  2. 1
      apps/api/src/app/portfolio/portfolio.service.ts
  3. 17
      apps/api/src/services/tag/tag.service.ts

35
apps/api/src/app/order/order.service.ts

@ -298,13 +298,30 @@ export class OrderService {
}
if (filtersByTag?.length > 0) {
where.tags = {
some: {
OR: filtersByTag.map(({ id }) => {
return { id };
})
where.OR = [
{
tags: {
some: {
OR: filtersByTag.map(({ id }) => {
return {
id: id
};
})
}
}
},
{
SymbolProfile: {
tags: {
some: {
OR: filtersByTag.map(({ id }) => {
return { id };
})
}
}
}
}
};
];
}
if (types) {
@ -330,7 +347,11 @@ export class OrderService {
}
},
// eslint-disable-next-line @typescript-eslint/naming-convention
SymbolProfile: true,
SymbolProfile: {
include: {
tags: true
}
},
tags: true
},
orderBy: { date: 'asc' }

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

@ -1190,6 +1190,7 @@ export class PortfolioService {
dataProviderResponses[position.symbol]?.marketState ?? 'delayed',
name: symbolProfileMap[position.symbol].name,
netPerformance: position.netPerformance?.toNumber() ?? null,
tags: symbolProfileMap[position.symbol].tags,
netPerformancePercentage:
position.netPerformancePercentage?.toNumber() ?? null,
quantity: new Big(position.quantity).toNumber()

17
apps/api/src/services/tag/tag.service.ts

@ -19,11 +19,20 @@ export class TagService {
name: 'asc'
},
where: {
orders: {
some: {
userId
OR: [
{
orders: {
some: {
userId
}
}
},
{
symbolProfile: {
some: {}
}
}
}
]
}
});
}

Loading…
Cancel
Save