Bugfix/add missing conversion of countries (#941)

* Add missing conversion of countries for SymbolProfileOverrides

* Update changelog
This commit is contained in:
Thomas Kaul 2022-05-23 18:04:09 +02:00 committed by GitHub
parent ae8a203526
commit f48832c671
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 17 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Fixed an issue with the missing conversion of countries in the symbol profile overrides
## 1.150.0 - 21.05.2022 ## 1.150.0 - 21.05.2022
### Changed ### Changed

View File

@ -59,7 +59,9 @@ export class SymbolProfileService {
return symbolProfiles.map((symbolProfile) => { return symbolProfiles.map((symbolProfile) => {
const item = { const item = {
...symbolProfile, ...symbolProfile,
countries: this.getCountries(symbolProfile), countries: this.getCountries(
symbolProfile?.countries as unknown as Prisma.JsonArray
),
scraperConfiguration: this.getScraperConfiguration(symbolProfile), scraperConfiguration: this.getScraperConfiguration(symbolProfile),
sectors: this.getSectors(symbolProfile), sectors: this.getSectors(symbolProfile),
symbolMapping: this.getSymbolMapping(symbolProfile) symbolMapping: this.getSymbolMapping(symbolProfile)
@ -70,9 +72,17 @@ export class SymbolProfileService {
item.SymbolProfileOverrides.assetClass ?? item.assetClass; item.SymbolProfileOverrides.assetClass ?? item.assetClass;
item.assetSubClass = item.assetSubClass =
item.SymbolProfileOverrides.assetSubClass ?? item.assetSubClass; item.SymbolProfileOverrides.assetSubClass ?? item.assetSubClass;
item.countries =
(item.SymbolProfileOverrides.countries as unknown as Country[]) ?? if (
item.countries; (item.SymbolProfileOverrides.countries as unknown as Prisma.JsonArray)
?.length > 0
) {
item.countries = this.getCountries(
item.SymbolProfileOverrides
?.countries as unknown as Prisma.JsonArray
);
}
item.name = item.SymbolProfileOverrides?.name ?? item.name; item.name = item.SymbolProfileOverrides?.name ?? item.name;
item.sectors = item.sectors =
(item.SymbolProfileOverrides.sectors as unknown as Sector[]) ?? (item.SymbolProfileOverrides.sectors as unknown as Sector[]) ??
@ -85,20 +95,22 @@ export class SymbolProfileService {
}); });
} }
private getCountries(symbolProfile: SymbolProfile): Country[] { private getCountries(aCountries: Prisma.JsonArray = []): Country[] {
return ((symbolProfile?.countries as Prisma.JsonArray) ?? []).map( if (aCountries === null) {
(country) => { return [];
const { code, weight } = country as Prisma.JsonObject; }
return { return aCountries.map((country: Pick<Country, 'code' | 'weight'>) => {
code: code as string, const { code, weight } = country;
continent:
continents[countries[code as string]?.continent] ?? UNKNOWN_KEY, return {
name: countries[code as string]?.name ?? UNKNOWN_KEY, code,
weight: weight as number weight,
}; continent:
} continents[countries[code as string]?.continent] ?? UNKNOWN_KEY,
); name: countries[code as string]?.name ?? UNKNOWN_KEY
};
});
} }
private getScraperConfiguration( private getScraperConfiguration(