Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

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

Thomas Kaulf36999691208
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca1310641c..245b719d98 100644
--- a/CHANGELOG.md
+++ b/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
+### Fixed
+
+- Fixed the symbol selection of the 7d data gathering
+
### Changed
- Used `dataSource` and `symbol` from `SymbolProfile` instead of the `order` object (in `ExportService` and `PortfolioService`)
diff --git a/apps/api/src/services/data-gathering.service.ts b/apps/api/src/services/data-gathering.service.ts
index 1098f20823..8fe2c48359 100644
--- a/apps/api/src/services/data-gathering.service.ts
+++ b/apps/api/src/services/data-gathering.service.ts
@@ -473,9 +473,18 @@ export class DataGatheringService {
private async getSymbols7D(): Promise<IDataGatheringItem[]> {
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
// 7 days
- const symbolsToGather = (
+ const symbolsNotToGather = (
await this.prismaService.marketData.groupBy({
_count: true,
by: ['symbol'],
@@ -485,24 +494,15 @@ export class DataGatheringService {
})
)
.filter((group) => {
- return group._count < 6;
+ return group._count >= 6;
})
.map((group) => {
return group.symbol;
});
- const symbolProfilesToGather = (
- await this.prismaService.symbolProfile.findMany({
- orderBy: [{ symbol: 'asc' }],
- select: {
- dataSource: true,
- scraperConfiguration: true,
- symbol: true
- }
- })
- )
+ const symbolProfilesToGather = symbolProfiles
.filter(({ symbol }) => {
- return symbolsToGather.includes(symbol);
+ return !symbolsNotToGather.includes(symbol);
})
.map((symbolProfile) => {
return {
@@ -514,7 +514,7 @@ export class DataGatheringService {
const currencyPairsToGather = this.exchangeRateDataService
.getCurrencyPairs()
.filter(({ symbol }) => {
- return symbolsToGather.includes(symbol);
+ return !symbolsNotToGather.includes(symbol);
})
.map(({ dataSource, symbol }) => {
return {