|
@ -4,7 +4,12 @@ import { UNKNOWN_KEY } from '@ghostfolio/common/config'; |
|
|
import { Country } from '@ghostfolio/common/interfaces/country.interface'; |
|
|
import { Country } from '@ghostfolio/common/interfaces/country.interface'; |
|
|
import { Sector } from '@ghostfolio/common/interfaces/sector.interface'; |
|
|
import { Sector } from '@ghostfolio/common/interfaces/sector.interface'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { Injectable } from '@nestjs/common'; |
|
|
import { DataSource, Prisma, SymbolProfile } from '@prisma/client'; |
|
|
import { |
|
|
|
|
|
DataSource, |
|
|
|
|
|
Prisma, |
|
|
|
|
|
SymbolProfile, |
|
|
|
|
|
SymbolProfileOverrides |
|
|
|
|
|
} from '@prisma/client'; |
|
|
import { continents, countries } from 'countries-list'; |
|
|
import { continents, countries } from 'countries-list'; |
|
|
|
|
|
|
|
|
import { ScraperConfiguration } from './data-provider/ghostfolio-scraper-api/interfaces/scraper-configuration.interface'; |
|
|
import { ScraperConfiguration } from './data-provider/ghostfolio-scraper-api/interfaces/scraper-configuration.interface'; |
|
@ -36,6 +41,7 @@ export class SymbolProfileService { |
|
|
): Promise<EnhancedSymbolProfile[]> { |
|
|
): Promise<EnhancedSymbolProfile[]> { |
|
|
return this.prismaService.symbolProfile |
|
|
return this.prismaService.symbolProfile |
|
|
.findMany({ |
|
|
.findMany({ |
|
|
|
|
|
include: { SymbolProfileOverrides: true }, |
|
|
where: { |
|
|
where: { |
|
|
symbol: { |
|
|
symbol: { |
|
|
in: symbols |
|
|
in: symbols |
|
@ -45,14 +51,38 @@ export class SymbolProfileService { |
|
|
.then((symbolProfiles) => this.getSymbols(symbolProfiles)); |
|
|
.then((symbolProfiles) => this.getSymbols(symbolProfiles)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getSymbols(symbolProfiles: SymbolProfile[]): EnhancedSymbolProfile[] { |
|
|
private getSymbols( |
|
|
return symbolProfiles.map((symbolProfile) => ({ |
|
|
symbolProfiles: (SymbolProfile & { |
|
|
...symbolProfile, |
|
|
SymbolProfileOverrides: SymbolProfileOverrides; |
|
|
countries: this.getCountries(symbolProfile), |
|
|
})[] |
|
|
scraperConfiguration: this.getScraperConfiguration(symbolProfile), |
|
|
): EnhancedSymbolProfile[] { |
|
|
sectors: this.getSectors(symbolProfile), |
|
|
return symbolProfiles.map((symbolProfile) => { |
|
|
symbolMapping: this.getSymbolMapping(symbolProfile) |
|
|
const item = { |
|
|
})); |
|
|
...symbolProfile, |
|
|
|
|
|
countries: this.getCountries(symbolProfile), |
|
|
|
|
|
scraperConfiguration: this.getScraperConfiguration(symbolProfile), |
|
|
|
|
|
sectors: this.getSectors(symbolProfile), |
|
|
|
|
|
symbolMapping: this.getSymbolMapping(symbolProfile) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (item.SymbolProfileOverrides) { |
|
|
|
|
|
item.assetClass = |
|
|
|
|
|
item.SymbolProfileOverrides.assetClass ?? item.assetClass; |
|
|
|
|
|
item.assetSubClass = |
|
|
|
|
|
item.SymbolProfileOverrides.assetSubClass ?? item.assetSubClass; |
|
|
|
|
|
item.countries = |
|
|
|
|
|
(item.SymbolProfileOverrides.sectors as unknown as Country[]) ?? |
|
|
|
|
|
item.countries; |
|
|
|
|
|
item.name = item.SymbolProfileOverrides?.name ?? item.name; |
|
|
|
|
|
item.sectors = |
|
|
|
|
|
(item.SymbolProfileOverrides.sectors as unknown as Sector[]) ?? |
|
|
|
|
|
item.sectors; |
|
|
|
|
|
|
|
|
|
|
|
delete item.SymbolProfileOverrides; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getCountries(symbolProfile: SymbolProfile): Country[] { |
|
|
private getCountries(symbolProfile: SymbolProfile): Country[] { |
|
|