From 5ff80de8c9f3d533c585bdaeb2f07858decb70ca Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 6 Jun 2026 09:32:08 +0200 Subject: [PATCH] Refactoring --- .../data-gathering/data-gathering.service.ts | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts index 9c3c7b6ca..f131c65c9 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts @@ -184,25 +184,19 @@ export class DataGatheringService { const symbolMapping = symbolProfile?.symbolMapping; - // Persist the data provider’s classification in the base asset profile; - // the asset profile override stays a separate layer applied at read time - const { - assetClass: assetClassFromDataProvider, - assetSubClass: assetSubClassFromDataProvider - } = assetProfile; - - // Apply the asset profile override so the data enhancers treat the asset - // profile correctly (e.g. enrich an ETF that the data provider classifies - // as a stock) - if (symbolProfile) { - assetProfile.assetClass = symbolProfile.assetClass; - assetProfile.assetSubClass = symbolProfile.assetSubClass; - } + let enhancedAssetProfile = symbolProfile + ? { + ...assetProfile, + assetClass: symbolProfile.assetClass ?? assetProfile.assetClass, + assetSubClass: + symbolProfile.assetSubClass ?? assetProfile.assetSubClass + } + : assetProfile; for (const dataEnhancer of this.dataEnhancers) { try { - assetProfiles[symbol] = await dataEnhancer.enhance({ - response: assetProfile, + enhancedAssetProfile = await dataEnhancer.enhance({ + response: enhancedAssetProfile, symbol: symbolMapping?.[dataEnhancer.getName()] ?? symbol }); } catch (error) { @@ -216,13 +210,11 @@ export class DataGatheringService { } } - // Restore the data provider’s classification before persisting - assetProfile.assetClass = assetClassFromDataProvider; - assetProfile.assetSubClass = assetSubClassFromDataProvider; + assetProfiles[symbol] = enhancedAssetProfile; + + const { assetClass, assetSubClass } = assetProfile; const { - assetClass, - assetSubClass, countries, currency, cusip, @@ -235,7 +227,7 @@ export class DataGatheringService { name, sectors, url - } = assetProfile; + } = enhancedAssetProfile; try { await this.prismaService.symbolProfile.upsert({