Browse Source

Minor improvements

pull/4296/head
Thomas Kaul 6 months ago
parent
commit
1d3fdf5f42
  1. 9
      apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts

9
apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts

@ -178,7 +178,7 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
requestTimeout: number; requestTimeout: number;
symbol: string; symbol: string;
}) { }) {
return await fetch( return fetch(
`https://www.trackinsight.com/search-api/search_v2/${symbol}/_/ticker/default/0/3`, `https://www.trackinsight.com/search-api/search_v2/${symbol}/_/ticker/default/0/3`,
{ {
signal: AbortSignal.timeout(requestTimeout) signal: AbortSignal.timeout(requestTimeout)
@ -186,10 +186,13 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface {
) )
.then((res) => res.json()) .then((res) => res.json())
.then((jsonRes) => { .then((jsonRes) => {
if (jsonRes['results']['count'] === 1) { if (
// Return the only ticker that matches the one in the search jsonRes['results']?.['count'] === 1 ||
jsonRes['results']?.['docs']?.[0]?.['ticker'] === symbol
) {
return jsonRes['results']['docs'][0]['ticker']; return jsonRes['results']['docs'][0]['ticker'];
} }
return undefined; return undefined;
}) })
.catch(() => { .catch(() => {

Loading…
Cancel
Save