Browse Source

Fix symbol selection of 7d data gathering

pull/670/head
Thomas 3 years ago
parent
commit
992c48f548
  1. 28
      apps/api/src/services/data-gathering.service.ts

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

@ -473,9 +473,18 @@ export class DataGatheringService {
private async getSymbols7D(): Promise<IDataGatheringItem[]> { private async getSymbols7D(): Promise<IDataGatheringItem[]> {
const startDate = subDays(resetHours(new Date()), 7); const startDate = subDays(resetHours(new Date()), 7);
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
select: {
dataSource: true,
scraperConfiguration: true,
symbol: true
}
});
// Only consider symbols with incomplete market data for the last // Only consider symbols with incomplete market data for the last
// 7 days // 7 days
const symbolsToGather = ( const symbolsNotToGather = (
await this.prismaService.marketData.groupBy({ await this.prismaService.marketData.groupBy({
_count: true, _count: true,
by: ['symbol'], by: ['symbol'],
@ -485,24 +494,15 @@ export class DataGatheringService {
}) })
) )
.filter((group) => { .filter((group) => {
return group._count < 6; return group._count >= 6;
}) })
.map((group) => { .map((group) => {
return group.symbol; return group.symbol;
}); });
const symbolProfilesToGather = ( const symbolProfilesToGather = symbolProfiles
await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
select: {
dataSource: true,
scraperConfiguration: true,
symbol: true
}
})
)
.filter(({ symbol }) => { .filter(({ symbol }) => {
return symbolsToGather.includes(symbol); return !symbolsNotToGather.includes(symbol);
}) })
.map((symbolProfile) => { .map((symbolProfile) => {
return { return {
@ -514,7 +514,7 @@ export class DataGatheringService {
const currencyPairsToGather = this.exchangeRateDataService const currencyPairsToGather = this.exchangeRateDataService
.getCurrencyPairs() .getCurrencyPairs()
.filter(({ symbol }) => { .filter(({ symbol }) => {
return symbolsToGather.includes(symbol); return !symbolsNotToGather.includes(symbol);
}) })
.map(({ dataSource, symbol }) => { .map(({ dataSource, symbol }) => {
return { return {

Loading…
Cancel
Save