|
|
|
@ -5,12 +5,12 @@ import { Sector } from '@ghostfolio/common/interfaces/sector.interface';
|
|
|
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
|
import { SymbolProfile } from '@prisma/client';
|
|
|
|
|
import { countries } from 'countries-list';
|
|
|
|
|
import got from 'got';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
|
|
|
|
|
private static baseUrl = 'https://www.trackinsight.com/data-api';
|
|
|
|
|
private static countries = require('countries-list/dist/countries.json');
|
|
|
|
|
private static countriesMapping = {
|
|
|
|
|
'Russian Federation': 'Russia'
|
|
|
|
|
};
|
|
|
|
@ -131,20 +131,19 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
|
|
|
|
|
(response.countries as unknown as Country[]).length === 0
|
|
|
|
|
) {
|
|
|
|
|
response.countries = [];
|
|
|
|
|
|
|
|
|
|
for (const [name, value] of Object.entries<any>(
|
|
|
|
|
holdings?.countries ?? {}
|
|
|
|
|
)) {
|
|
|
|
|
let countryCode: string;
|
|
|
|
|
|
|
|
|
|
for (const [key, country] of Object.entries<any>(
|
|
|
|
|
TrackinsightDataEnhancerService.countries
|
|
|
|
|
)) {
|
|
|
|
|
for (const [code, country] of Object.entries(countries)) {
|
|
|
|
|
if (
|
|
|
|
|
country.name === name ||
|
|
|
|
|
country.name ===
|
|
|
|
|
TrackinsightDataEnhancerService.countriesMapping[name]
|
|
|
|
|
) {
|
|
|
|
|
countryCode = key;
|
|
|
|
|
countryCode = code;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|