Browse Source

Refactoring

pull/3723/head
Thomas Kaul 12 months ago
parent
commit
dcc5ffe790
  1. 23
      apps/api/src/services/data-provider/manual/manual.service.ts
  2. 2
      apps/api/src/services/symbol-profile/symbol-profile.service.ts

23
apps/api/src/services/data-provider/manual/manual.service.ts

@ -166,25 +166,24 @@ export class ManualService implements DataProviderInterface {
}
});
const symbolProfilesWithScraperConfiguration = symbolProfiles.filter(
({ scraperConfiguration }) => {
return !!scraperConfiguration?.url;
}
);
const symbolProfilesWithScraperConfigurationAndInstantMode =
symbolProfiles.filter(({ scraperConfiguration }) => {
return scraperConfiguration?.mode === 'instant';
});
const scraperResultPromises = symbolProfilesWithScraperConfiguration.map(
({ scraperConfiguration, symbol }) => {
return this.scrape(scraperConfiguration)
.then((marketPrice) => {
const scraperResultPromises =
symbolProfilesWithScraperConfigurationAndInstantMode.map(
async ({ scraperConfiguration, symbol }) => {
try {
const marketPrice = await this.scrape(scraperConfiguration);
return { marketPrice, symbol };
})
.catch((error) => {
} catch (error) {
Logger.error(
`Could not get quote for ${symbol} (${this.getName()}): [${error.name}] ${error.message}`,
'ManualService'
);
return { symbol, marketPrice: undefined };
});
}
}
);

2
apps/api/src/services/symbol-profile/symbol-profile.service.ts

@ -275,6 +275,8 @@ export class SymbolProfileService {
headers:
scraperConfiguration.headers as ScraperConfiguration['headers'],
locale: scraperConfiguration.locale as string,
mode:
(scraperConfiguration.mode as ScraperConfiguration['mode']) ?? 'lazy',
selector: scraperConfiguration.selector as string,
url: scraperConfiguration.url as string
};

Loading…
Cancel
Save