From 2692c362fcca480d07afa03b107c706b95809474 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 27 Feb 2022 10:35:10 +0100 Subject: [PATCH] Add url to symbol profile --- apps/api/src/services/data-gathering.service.ts | 17 +++++++++++------ .../yahoo-finance/yahoo-finance.service.ts | 9 ++++----- prisma/schema.prisma | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/api/src/services/data-gathering.service.ts b/apps/api/src/services/data-gathering.service.ts index 0038a7dd8..1bd6b5a55 100644 --- a/apps/api/src/services/data-gathering.service.ts +++ b/apps/api/src/services/data-gathering.service.ts @@ -220,9 +220,11 @@ export class DataGatheringService { Logger.log('Profile data gathering has been started.'); console.time('data-gathering-profile'); - let dataGatheringItems = aDataGatheringItems.filter((dataGatheringItem) => { - return dataGatheringItem.dataSource !== 'MANUAL'; - }); + let dataGatheringItems = aDataGatheringItems?.filter( + (dataGatheringItem) => { + return dataGatheringItem.dataSource !== 'MANUAL'; + } + ); if (!dataGatheringItems) { dataGatheringItems = await this.getSymbolsProfileData(); @@ -260,7 +262,8 @@ export class DataGatheringService { currency, dataSource, name, - sectors + sectors, + url } = assetProfiles[symbol]; try { @@ -273,7 +276,8 @@ export class DataGatheringService { dataSource, name, sectors, - symbol + symbol, + url }, update: { assetClass, @@ -281,7 +285,8 @@ export class DataGatheringService { countries, currency, name, - sectors + sectors, + url }, where: { dataSource_symbol: { 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 65f34045f..0014cde3f 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 @@ -119,11 +119,10 @@ export class YahooFinanceService implements DataProviderInterface { } } - // TODO: Add url if available - /*const url = assetProfile.summaryProfile?.website; - if (url) { - response.url = url; - }*/ + const url = assetProfile.summaryProfile?.website; + if (url) { + response.url = url; + } } catch {} return response; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c57ff8051..bea0e3381 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -129,6 +129,7 @@ model SymbolProfile { sectors Json? symbol String symbolMapping Json? + url String? @@unique([dataSource, symbol]) }