Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/add missing conversion of countries (#941)
Thomas Kaulf48832c671c6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d0b90eda11..5d195d5ca4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -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/),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### Changeddiff --git a/apps/api/src/services/symbol-profile.service.ts b/apps/api/src/services/symbol-profile.service.tsindex 5c8839ebf5..d7a0c4cfdc 100644--- a/apps/api/src/services/symbol-profile.service.ts+++ b/apps/api/src/services/symbol-profile.service.ts@@ -59,7 +59,9 @@ export class SymbolProfileService {return symbolProfiles.map((symbolProfile) => {const item = {...symbolProfile,- countries: this.getCountries(symbolProfile),+ countries: this.getCountries(+ symbolProfile?.countries as unknown as Prisma.JsonArray+ ),scraperConfiguration: this.getScraperConfiguration(symbolProfile),sectors: this.getSectors(symbolProfile),symbolMapping: this.getSymbolMapping(symbolProfile)@@ -70,9 +72,17 @@ export class SymbolProfileService {item.SymbolProfileOverrides.assetClass ?? item.assetClass;item.assetSubClass =item.SymbolProfileOverrides.assetSubClass ?? item.assetSubClass;- item.countries =- (item.SymbolProfileOverrides.countries as unknown as Country[]) ??- item.countries;++ if (+ (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.sectors =(item.SymbolProfileOverrides.sectors as unknown as Sector[]) ??@@ -85,20 +95,22 @@ export class SymbolProfileService {});}- private getCountries(symbolProfile: SymbolProfile): Country[] {- return ((symbolProfile?.countries as Prisma.JsonArray) ?? []).map(- (country) => {- const { code, weight } = country as Prisma.JsonObject;+ private getCountries(aCountries: Prisma.JsonArray = []): Country[] {+ if (aCountries === null) {+ return [];+ }- return {- code: code as string,- continent:- continents[countries[code as string]?.continent] ?? UNKNOWN_KEY,- name: countries[code as string]?.name ?? UNKNOWN_KEY,- weight: weight as number- };- }- );+ return aCountries.map((country: Pick<Country, 'code' | 'weight'>) => {+ const { code, weight } = country;++ return {+ code,+ weight,+ continent:+ continents[countries[code as string]?.continent] ?? UNKNOWN_KEY,+ name: countries[code as string]?.name ?? UNKNOWN_KEY+ };+ });}private getScraperConfiguration(