Browse Source

Refactoring

pull/1791/head
Thomas 3 years ago
parent
commit
0195735094
  1. 1
      apps/api/src/app/import/import.service.ts
  2. 13
      apps/api/src/services/data-gathering.service.ts
  3. 3
      apps/api/src/services/data-provider/data-provider.service.ts
  4. 8
      apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts
  5. 2
      prisma/migrations/20230318081658_added_isin_to_symbol_profile/migration.sql
  6. 1
      prisma/schema.prisma

1
apps/api/src/app/import/import.service.ts

@ -254,6 +254,7 @@ export class ImportService {
countries: null,
createdAt: undefined,
id: undefined,
isin: null,
name: null,
scraperConfiguration: null,
sectors: null,

13
apps/api/src/services/data-gathering.service.ts

@ -127,11 +127,9 @@ export class DataGatheringService {
);
for (const [symbol, assetProfile] of Object.entries(assetProfiles)) {
const symbolMapping =
assetProfile.symbolMapping ??
symbolProfiles.find((symbolProfile) => {
return symbolProfile.symbol === symbol;
})?.symbolMapping;
const symbolMapping = symbolProfiles.find((symbolProfile) => {
return symbolProfile.symbol === symbol;
})?.symbolMapping;
for (const dataEnhancer of this.dataEnhancers) {
try {
@ -154,6 +152,7 @@ export class DataGatheringService {
countries,
currency,
dataSource,
isin,
name,
sectors,
url
@ -167,10 +166,10 @@ export class DataGatheringService {
countries,
currency,
dataSource,
isin,
name,
sectors,
symbol,
symbolMapping,
url
},
update: {
@ -178,9 +177,9 @@ export class DataGatheringService {
assetSubClass,
countries,
currency,
isin,
name,
sectors,
symbolMapping,
url
},
where: {

3
apps/api/src/services/data-provider/data-provider.service.ts

@ -323,6 +323,7 @@ export class DataProviderService {
}
private isPremiumDataSource(aDataSource: DataSource) {
return aDataSource === DataSource.EOD_HISTORICAL_DATA;
const premiumDataSources: DataSource[] = [DataSource.EOD_HISTORICAL_DATA];
return premiumDataSources.includes(aDataSource);
}
}

8
apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts

@ -37,18 +37,12 @@ export class EodHistoricalDataService implements DataProviderInterface {
): Promise<Partial<SymbolProfile>> {
const [searchResult] = await this.getSearchResult(aSymbol);
const symbolMapping = searchResult?.ISIN
? {
ISIN: searchResult.ISIN
}
: undefined;
return {
symbolMapping,
assetClass: searchResult?.assetClass,
assetSubClass: searchResult?.assetSubClass,
currency: searchResult?.currency,
dataSource: this.getName(),
isin: searchResult?.ISIN,
name: searchResult?.name
};
}

2
prisma/migrations/20230318081658_added_isin_to_symbol_profile/migration.sql

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "SymbolProfile" ADD COLUMN "isin" TEXT;

1
prisma/schema.prisma

@ -119,6 +119,7 @@ model SymbolProfile {
currency String
dataSource DataSource
id String @id @default(uuid())
isin String?
name String?
updatedAt DateTime @updatedAt
scraperConfiguration Json?

Loading…
Cancel
Save