Browse Source

Refactoring

pull/1857/head
Thomas 2 years ago
parent
commit
8c1db4c87f
  1. 56
      apps/api/src/app/admin/admin.controller.ts
  2. 28
      apps/api/src/services/cron.service.ts

56
apps/api/src/app/admin/admin.controller.ts

@ -100,19 +100,21 @@ export class AdminController {
const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
for (const { dataSource, symbol } of uniqueAssets) { await this.dataGatheringService.addJobsToQueue(
await this.dataGatheringService.addJobToQueue({ uniqueAssets.map(({ dataSource, symbol }) => {
data: { return {
dataSource, data: {
symbol dataSource,
}, symbol
name: GATHER_ASSET_PROFILE_PROCESS, },
opts: { name: GATHER_ASSET_PROFILE_PROCESS,
...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, opts: {
jobId: `${dataSource}-${symbol}}` ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS,
} jobId: `${dataSource}-${symbol}}`
}); }
} };
})
);
this.dataGatheringService.gatherMax(); this.dataGatheringService.gatherMax();
} }
@ -134,19 +136,21 @@ export class AdminController {
const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
for (const { dataSource, symbol } of uniqueAssets) { await this.dataGatheringService.addJobsToQueue(
await this.dataGatheringService.addJobToQueue({ uniqueAssets.map(({ dataSource, symbol }) => {
data: { return {
dataSource, data: {
symbol dataSource,
}, symbol
name: GATHER_ASSET_PROFILE_PROCESS, },
opts: { name: GATHER_ASSET_PROFILE_PROCESS,
...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, opts: {
jobId: `${dataSource}-${symbol}}` ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS,
} jobId: `${dataSource}-${symbol}}`
}); }
} };
})
);
} }
@Post('gather/profile-data/:dataSource/:symbol') @Post('gather/profile-data/:dataSource/:symbol')

28
apps/api/src/services/cron.service.ts

@ -38,18 +38,20 @@ export class CronService {
public async runEverySundayAtTwelvePm() { public async runEverySundayAtTwelvePm() {
const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); const uniqueAssets = await this.dataGatheringService.getUniqueAssets();
for (const { dataSource, symbol } of uniqueAssets) { await this.dataGatheringService.addJobsToQueue(
await this.dataGatheringService.addJobToQueue({ uniqueAssets.map(({ dataSource, symbol }) => {
data: { return {
dataSource, data: {
symbol dataSource,
}, symbol
name: GATHER_ASSET_PROFILE_PROCESS, },
opts: { name: GATHER_ASSET_PROFILE_PROCESS,
...GATHER_ASSET_PROFILE_PROCESS_OPTIONS, opts: {
jobId: `${dataSource}-${symbol}}` ...GATHER_ASSET_PROFILE_PROCESS_OPTIONS,
} jobId: `${dataSource}-${symbol}}`
}); }
} };
})
);
} }
} }

Loading…
Cancel
Save