Browse Source

Fix Tags on orders (SymbolProfile)

pull/5027/head
Dan 5 months ago
parent
commit
3cad76b6f8
  1. 27
      apps/api/src/app/order/order.service.ts

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

@ -27,8 +27,7 @@ import {
Order,
Prisma,
Tag,
Type as ActivityType,
SymbolProfile
Type as ActivityType
} from '@prisma/client';
import { Big } from 'big.js';
import { endOfToday, isAfter } from 'date-fns';
@ -54,22 +53,34 @@ export class OrderService {
userId,
tags
}: { tags: Tag[]; userId: string } & AssetProfileIdentifier) {
const symbolProfile: SymbolProfile =
await this.symbolProfileService.getSymbolProfiles([
const promis = await this.symbolProfileService.getSymbolProfiles([
{
dataSource,
symbol
}
])[0];
]);
const symbolProfile: EnhancedSymbolProfile = promis[0];
const result = await this.symbolProfileService.updateSymbolProfile({
assetClass: symbolProfile.assetClass,
assetSubClass: symbolProfile.assetSubClass,
countries: symbolProfile.countries,
countries: symbolProfile.countries.reduce(
(all, v) => [...all, { code: v.code, weight: v.weight }],
[]
),
currency: symbolProfile.currency,
dataSource,
holdings: symbolProfile.holdings,
holdings: symbolProfile.holdings.reduce(
(all, v) => [
...all,
{ name: v.name, weight: v.allocationInPercentage }
],
[]
),
name: symbolProfile.name,
sectors: symbolProfile.sectors,
sectors: symbolProfile.sectors.reduce(
(all, v) => [...all, { name: v.name, weight: v.weight }],
[]
),
symbol,
tags: {
connectOrCreate: tags.map(({ id, name }) => {

Loading…
Cancel
Save