diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index 6d34f8cdb..38b6157b3 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/apps/api/src/app/admin/admin.controller.ts @@ -101,17 +101,17 @@ export class AdminController { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue( - GATHER_ASSET_PROFILE_PROCESS, - { + await this.dataGatheringService.addJobToQueue({ + data: { dataSource, symbol }, - { + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, jobId: `${dataSource}-${symbol}}` } - ); + }); } this.dataGatheringService.gatherMax(); @@ -135,17 +135,17 @@ export class AdminController { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue( - GATHER_ASSET_PROFILE_PROCESS, - { + await this.dataGatheringService.addJobToQueue({ + data: { dataSource, symbol }, - { + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, jobId: `${dataSource}-${symbol}}` } - ); + }); } } @@ -167,17 +167,17 @@ export class AdminController { ); } - await this.dataGatheringService.addJobToQueue( - GATHER_ASSET_PROFILE_PROCESS, - { + await this.dataGatheringService.addJobToQueue({ + data: { dataSource, symbol }, - { + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, jobId: `${dataSource}-${symbol}}` } - ); + }); } @Post('gather/:dataSource/:symbol') diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index 50cc3bf71..4080c5c34 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -112,17 +112,17 @@ export class OrderService { }; } - await this.dataGatheringService.addJobToQueue( - GATHER_ASSET_PROFILE_PROCESS, - { + await this.dataGatheringService.addJobToQueue({ + data: { dataSource: data.SymbolProfile.connectOrCreate.create.dataSource, symbol: data.SymbolProfile.connectOrCreate.create.symbol }, - { + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, jobId: `${data.SymbolProfile.connectOrCreate.create.dataSource}-${data.SymbolProfile.connectOrCreate.create.symbol}}` } - ); + }); const isDraft = isAfter(data.date as Date, endOfToday()); diff --git a/apps/api/src/services/cron.service.ts b/apps/api/src/services/cron.service.ts index 1eb5432c6..6024c50cd 100644 --- a/apps/api/src/services/cron.service.ts +++ b/apps/api/src/services/cron.service.ts @@ -39,17 +39,17 @@ export class CronService { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue( - GATHER_ASSET_PROFILE_PROCESS, - { + await this.dataGatheringService.addJobToQueue({ + data: { dataSource, symbol }, - { + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, jobId: `${dataSource}-${symbol}}` } - ); + }); } } } diff --git a/apps/api/src/services/data-gathering.service.ts b/apps/api/src/services/data-gathering.service.ts index cad0b9e21..5de70c925 100644 --- a/apps/api/src/services/data-gathering.service.ts +++ b/apps/api/src/services/data-gathering.service.ts @@ -34,7 +34,15 @@ export class DataGatheringService { private readonly symbolProfileService: SymbolProfileService ) {} - public async addJobToQueue(name: string, data: any, opts?: JobOptions) { + public async addJobToQueue({ + data, + name, + opts + }: { + data: any; + name: string; + opts?: JobOptions; + }) { return this.dataGatheringQueue.add(name, data, opts); }