Browse Source

Bugfix/fix symbol selection of 7d data gathering (#670)

* Fix symbol selection of 7d data gathering

* Update changelog
pull/671/head
Thomas Kaul 3 years ago
committed by GitHub
parent
commit
f369996912
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 28
      apps/api/src/services/data-gathering.service.ts

4
CHANGELOG.md

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for deleting symbol profile data in the admin control panel - Added support for deleting symbol profile data in the admin control panel
### Fixed
- Fixed the symbol selection of the 7d data gathering
### Changed ### Changed
- Used `dataSource` and `symbol` from `SymbolProfile` instead of the `order` object (in `ExportService` and `PortfolioService`) - Used `dataSource` and `symbol` from `SymbolProfile` instead of the `order` object (in `ExportService` and `PortfolioService`)

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