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