diff --git a/apps/api/src/app/admin/admin.controller.ts b/apps/api/src/app/admin/admin.controller.ts index 38b6157b3..c32ecf03b 100644 --- a/apps/api/src/app/admin/admin.controller.ts +++ b/apps/api/src/app/admin/admin.controller.ts @@ -100,19 +100,21 @@ export class AdminController { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); - for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue({ - data: { - dataSource, - symbol - }, - name: GATHER_ASSET_PROFILE_PROCESS, - opts: { - ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, - jobId: `${dataSource}-${symbol}}` - } - }); - } + await this.dataGatheringService.addJobsToQueue( + uniqueAssets.map(({ dataSource, symbol }) => { + return { + data: { + dataSource, + symbol + }, + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { + ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, + jobId: `${dataSource}-${symbol}}` + } + }; + }) + ); this.dataGatheringService.gatherMax(); } @@ -134,19 +136,21 @@ export class AdminController { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); - for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue({ - data: { - dataSource, - symbol - }, - name: GATHER_ASSET_PROFILE_PROCESS, - opts: { - ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, - jobId: `${dataSource}-${symbol}}` - } - }); - } + await this.dataGatheringService.addJobsToQueue( + uniqueAssets.map(({ dataSource, symbol }) => { + return { + data: { + dataSource, + symbol + }, + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { + ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, + jobId: `${dataSource}-${symbol}}` + } + }; + }) + ); } @Post('gather/profile-data/:dataSource/:symbol') diff --git a/apps/api/src/services/cron.service.ts b/apps/api/src/services/cron.service.ts index 6024c50cd..bf186b32f 100644 --- a/apps/api/src/services/cron.service.ts +++ b/apps/api/src/services/cron.service.ts @@ -38,18 +38,20 @@ export class CronService { public async runEverySundayAtTwelvePm() { const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); - for (const { dataSource, symbol } of uniqueAssets) { - await this.dataGatheringService.addJobToQueue({ - data: { - dataSource, - symbol - }, - name: GATHER_ASSET_PROFILE_PROCESS, - opts: { - ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, - jobId: `${dataSource}-${symbol}}` - } - }); - } + await this.dataGatheringService.addJobsToQueue( + uniqueAssets.map(({ dataSource, symbol }) => { + return { + data: { + dataSource, + symbol + }, + name: GATHER_ASSET_PROFILE_PROCESS, + opts: { + ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, + jobId: `${dataSource}-${symbol}}` + } + }; + }) + ); } }