Browse Source

Improve data gathering for currencies, add warning if it fails

pull/581/head
Thomas 4 years ago
parent
commit
285062da7f
  1. 16
      apps/api/src/services/data-gathering.service.ts

16
apps/api/src/services/data-gathering.service.ts

@ -334,6 +334,7 @@ export class DataGatheringService {
?.marketPrice;
}
if (lastMarketPrice) {
try {
await this.prismaService.marketData.create({
data: {
@ -344,6 +345,14 @@ export class DataGatheringService {
}
});
} catch {}
} else {
Logger.warn(
`Failed to gather data for symbol ${symbol} at ${format(
currentDate,
DATE_FORMAT
)}.`
);
}
// Count month one up for iteration
currentDate = new Date(
@ -492,8 +501,8 @@ export class DataGatheringService {
}
})
)
.filter((symbolProfile) => {
return symbolsToGather.includes(symbolProfile.symbol);
.filter(({ symbol }) => {
return symbolsToGather.includes(symbol);
})
.map((symbolProfile) => {
return {
@ -504,6 +513,9 @@ export class DataGatheringService {
const currencyPairsToGather = this.exchangeRateDataService
.getCurrencyPairs()
.filter(({ symbol }) => {
return symbolsToGather.includes(symbol);
})
.map(({ dataSource, symbol }) => {
return {
dataSource,

Loading…
Cancel
Save