From a541f6302d040f24c75fdb50515c8a628e38ace5 Mon Sep 17 00:00:00 2001 From: bptrgx <47859535+bptrgx@users.noreply.github.com> Date: Fri, 7 Jul 2023 13:12:20 +0200 Subject: [PATCH] Fetch SymbolProfileOverrides for orders symbols name --- apps/api/src/app/order/order.service.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index be5708a90..2079b990e 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -7,7 +7,7 @@ import { GATHER_ASSET_PROFILE_PROCESS, GATHER_ASSET_PROFILE_PROCESS_OPTIONS } from '@ghostfolio/common/config'; -import { Filter } from '@ghostfolio/common/interfaces'; +import { Filter, UniqueAsset } from '@ghostfolio/common/interfaces'; import { OrderWithAccount } from '@ghostfolio/common/types'; import { Injectable } from '@nestjs/common'; import { @@ -305,7 +305,7 @@ export class OrderService { }); } - return ( + let orders = ( await this.orders({ where, include: { @@ -347,6 +347,23 @@ export class OrderService { ) }; }); + + let ordersAssets: UniqueAsset[] = orders.map((order) => { + return { + dataSource: order.SymbolProfile.dataSource, + symbol: order.SymbolProfile.symbol, + }; + }); + + let symbolProfiles = await this.symbolProfileService.getSymbolProfiles(ordersAssets); + + return orders.map((order) => { + let symbolProfileWithOverride = symbolProfiles.find(symbolProfile => symbolProfile.symbol === order.SymbolProfile.symbol); + if (symbolProfileWithOverride.name) { + order.SymbolProfile.name = symbolProfileWithOverride.name; + } + return order; + }); } public async updateOrder({