diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index a761bbbae..409ce7160 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/apps/api/src/app/admin/admin.controller.ts @@ -83,7 +83,7 @@ export class AdminController { @UseGuards(AuthGuard('jwt'), HasPermissionGuard) public async gatherMax(): Promise { const assetProfileIdentifiers = - await this.dataGatheringService.getAllAssetProfileIdentifiers(); + await this.dataGatheringService.getAllActiveAssetProfileIdentifiers(); await this.dataGatheringService.addJobsToQueue( assetProfileIdentifiers.map(({ dataSource, symbol }) => { @@ -110,7 +110,7 @@ export class AdminController { @UseGuards(AuthGuard('jwt'), HasPermissionGuard) public async gatherProfileData(): Promise { const assetProfileIdentifiers = - await this.dataGatheringService.getAllAssetProfileIdentifiers(); + await this.dataGatheringService.getAllActiveAssetProfileIdentifiers(); await this.dataGatheringService.addJobsToQueue( assetProfileIdentifiers.map(({ dataSource, symbol }) => { diff --git a/apps/api/src/services/cron.service.ts b/apps/api/src/services/cron.service.ts index 7a1b30b5f..088348d85 100644 --- a/apps/api/src/services/cron.service.ts +++ b/apps/api/src/services/cron.service.ts @@ -57,7 +57,7 @@ export class CronService { public async runEverySundayAtTwelvePm() { if (await this.isDataGatheringEnabled()) { const assetProfileIdentifiers = - await this.dataGatheringService.getAllAssetProfileIdentifiers(); + await this.dataGatheringService.getAllActiveAssetProfileIdentifiers(); await this.dataGatheringService.addJobsToQueue( assetProfileIdentifiers.map(({ dataSource, symbol }) => { diff --git a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts index 778e432c8..90a269315 100644 --- a/apps/api/src/services/queues/data-gathering/data-gathering.service.ts +++ b/apps/api/src/services/queues/data-gathering/data-gathering.service.ts @@ -159,7 +159,8 @@ export class DataGatheringService { ); if (!assetProfileIdentifiers) { - assetProfileIdentifiers = await this.getAllAssetProfileIdentifiers(); + assetProfileIdentifiers = + await this.getAllActiveAssetProfileIdentifiers(); } if (assetProfileIdentifiers.length <= 0) { @@ -296,7 +297,7 @@ export class DataGatheringService { ); } - public async getAllAssetProfileIdentifiers(): Promise< + public async getAllActiveAssetProfileIdentifiers(): Promise< AssetProfileIdentifier[] > { const symbolProfiles = await this.prismaService.symbolProfile.findMany({ @@ -373,9 +374,11 @@ export class DataGatheringService { withUserSubscription?: boolean; }): Promise { const symbolProfiles = - await this.symbolProfileService.getSymbolProfilesByUserSubscription({ - withUserSubscription - }); + await this.symbolProfileService.getActiveSymbolProfilesByUserSubscription( + { + withUserSubscription + } + ); const assetProfileIdentifiersWithCompleteMarketData = await this.getAssetProfileIdentifiersWithCompleteMarketData(); diff --git a/apps/api/src/services/symbol-profile/symbol-profile.service.ts b/apps/api/src/services/symbol-profile/symbol-profile.service.ts index 98c17a617..e9c568cef 100644 --- a/apps/api/src/services/symbol-profile/symbol-profile.service.ts +++ b/apps/api/src/services/symbol-profile/symbol-profile.service.ts @@ -35,6 +35,41 @@ export class SymbolProfileService { }); } + public async getActiveSymbolProfilesByUserSubscription({ + withUserSubscription = false + }: { + withUserSubscription?: boolean; + }) { + return this.prismaService.symbolProfile.findMany({ + include: { + Order: { + include: { + User: true + } + } + }, + orderBy: [{ symbol: 'asc' }], + where: { + isActive: true, + Order: withUserSubscription + ? { + some: { + User: { + Subscription: { some: { expiresAt: { gt: new Date() } } } + } + } + } + : { + every: { + User: { + Subscription: { none: { expiresAt: { gt: new Date() } } } + } + } + } + } + }); + } + public async getSymbolProfiles( aAssetProfileIdentifiers: AssetProfileIdentifier[] ): Promise { @@ -91,41 +126,6 @@ export class SymbolProfileService { }); } - public async getSymbolProfilesByUserSubscription({ - withUserSubscription = false - }: { - withUserSubscription?: boolean; - }) { - return this.prismaService.symbolProfile.findMany({ - include: { - Order: { - include: { - User: true - } - } - }, - orderBy: [{ symbol: 'asc' }], - where: { - isActive: true, - Order: withUserSubscription - ? { - some: { - User: { - Subscription: { some: { expiresAt: { gt: new Date() } } } - } - } - } - : { - every: { - User: { - Subscription: { none: { expiresAt: { gt: new Date() } } } - } - } - } - } - }); - } - public updateSymbolProfile({ assetClass, assetSubClass,