From 0ea845100b7beff5094da993d723ffa4036e3888 Mon Sep 17 00:00:00 2001 From: csehatt741 Date: Fri, 11 Apr 2025 09:55:12 +0200 Subject: [PATCH] Code review changes --- CHANGELOG.md | 2 +- .../asset-profile-delisted.error.ts | 2 +- .../yahoo-finance/yahoo-finance.service.ts | 3 +-- .../data-gathering/data-gathering.processor.ts | 12 ++++++------ 4 files changed, 9 insertions(+), 10 deletions(-) rename apps/api/src/services/data-provider/{yahoo-finance => errors}/asset-profile-delisted.error.ts (75%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9df19597..6a3a2c46e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added the data gathering status column to the historical market data table of the admin control -- Deactivated asset profile on delisting (Yahoo Finance) +- Deactivated asset profiles automatically on delisting in the _Yahoo Finance_ service ### Changed diff --git a/apps/api/src/services/data-provider/yahoo-finance/asset-profile-delisted.error.ts b/apps/api/src/services/data-provider/errors/asset-profile-delisted.error.ts similarity index 75% rename from apps/api/src/services/data-provider/yahoo-finance/asset-profile-delisted.error.ts rename to apps/api/src/services/data-provider/errors/asset-profile-delisted.error.ts index 715001598..d326ee74b 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/asset-profile-delisted.error.ts +++ b/apps/api/src/services/data-provider/errors/asset-profile-delisted.error.ts @@ -1,5 +1,5 @@ export class AssetProfileDelistedError extends Error { - constructor(message: string) { + public constructor(message: string) { super(message); this.name = 'AssetProfileDelistedError'; } diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts index 58a9432d8..d8f4a143f 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts @@ -1,5 +1,6 @@ import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service'; import { YahooFinanceDataEnhancerService } from '@ghostfolio/api/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service'; +import { AssetProfileDelistedError } from '@ghostfolio/api/services/data-provider/errors/asset-profile-delisted.error'; import { DataProviderInterface, GetAssetProfileParams, @@ -31,8 +32,6 @@ import { } from 'yahoo-finance2/dist/esm/src/modules/historical'; import { Quote } from 'yahoo-finance2/dist/esm/src/modules/quote'; -import { AssetProfileDelistedError } from './asset-profile-delisted.error'; - @Injectable() export class YahooFinanceService implements DataProviderInterface { public constructor( diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.processor.ts b/apps/api/src/services/queues/data-gathering/data-gathering.processor.ts index 3e011f6e6..d7fcc5ab3 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.processor.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.processor.ts @@ -1,5 +1,5 @@ import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; -import { AssetProfileDelistedError } from '@ghostfolio/api/services/data-provider/yahoo-finance/asset-profile-delisted.error'; +import { AssetProfileDelistedError } from '@ghostfolio/api/services/data-provider/errors/asset-profile-delisted.error'; import { IDataGatheringItem } from '@ghostfolio/api/services/interfaces/interfaces'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; @@ -147,17 +147,17 @@ export class DataGatheringProcessor { ); } catch (error) { if (error instanceof AssetProfileDelistedError) { - const updatedSymbolProfile: Prisma.SymbolProfileUpdateInput = { - isActive: false - }; - await this.symbolProfileService.updateSymbolProfile( { dataSource, symbol }, - updatedSymbolProfile + { + isActive: false + } ); + + await job.discard(); } Logger.error(