|
|
@ -2,9 +2,8 @@ import { DataGatheringService } from '@ghostfolio/api/services/data-gathering.se |
|
|
|
import { MarketDataService } from '@ghostfolio/api/services/market-data.service'; |
|
|
|
import { PropertyDto } from '@ghostfolio/api/services/property/property.dto'; |
|
|
|
import { |
|
|
|
DATA_GATHERING_QUEUE, |
|
|
|
DATA_GATHERING_QUEUE_PRIORITY_HIGH, |
|
|
|
GATHER_ASSET_PROFILE_PROCESS |
|
|
|
GATHER_ASSET_PROFILE_PROCESS, |
|
|
|
GATHER_ASSET_PROFILE_PROCESS_OPTIONS |
|
|
|
} from '@ghostfolio/common/config'; |
|
|
|
import { |
|
|
|
AdminData, |
|
|
@ -13,7 +12,6 @@ import { |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
import type { RequestWithUser } from '@ghostfolio/common/types'; |
|
|
|
import { InjectQueue } from '@nestjs/bull'; |
|
|
|
import { |
|
|
|
Body, |
|
|
|
Controller, |
|
|
@ -29,10 +27,8 @@ import { |
|
|
|
import { REQUEST } from '@nestjs/core'; |
|
|
|
import { AuthGuard } from '@nestjs/passport'; |
|
|
|
import { DataSource, MarketData } from '@prisma/client'; |
|
|
|
import { Queue } from 'bull'; |
|
|
|
import { isDate } from 'date-fns'; |
|
|
|
import { StatusCodes, getReasonPhrase } from 'http-status-codes'; |
|
|
|
import ms from 'ms'; |
|
|
|
|
|
|
|
import { AdminService } from './admin.service'; |
|
|
|
import { UpdateMarketDataDto } from './update-market-data.dto'; |
|
|
@ -41,8 +37,6 @@ import { UpdateMarketDataDto } from './update-market-data.dto'; |
|
|
|
export class AdminController { |
|
|
|
public constructor( |
|
|
|
private readonly adminService: AdminService, |
|
|
|
@InjectQueue(DATA_GATHERING_QUEUE) |
|
|
|
private readonly dataGatheringQueue: Queue, |
|
|
|
private readonly dataGatheringService: DataGatheringService, |
|
|
|
private readonly marketDataService: MarketDataService, |
|
|
|
@Inject(REQUEST) private readonly request: RequestWithUser |
|
|
@ -102,20 +96,13 @@ export class AdminController { |
|
|
|
const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); |
|
|
|
|
|
|
|
for (const { dataSource, symbol } of uniqueAssets) { |
|
|
|
await this.dataGatheringQueue.add( |
|
|
|
await this.dataGatheringService.addJobToQueue( |
|
|
|
GATHER_ASSET_PROFILE_PROCESS, |
|
|
|
{ |
|
|
|
dataSource, |
|
|
|
symbol |
|
|
|
}, |
|
|
|
{ |
|
|
|
attempts: 20, |
|
|
|
backoff: { |
|
|
|
delay: ms('1 minute'), |
|
|
|
type: 'exponential' |
|
|
|
}, |
|
|
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH |
|
|
|
} |
|
|
|
GATHER_ASSET_PROFILE_PROCESS_OPTIONS |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@ -140,20 +127,13 @@ export class AdminController { |
|
|
|
const uniqueAssets = await this.dataGatheringService.getUniqueAssets(); |
|
|
|
|
|
|
|
for (const { dataSource, symbol } of uniqueAssets) { |
|
|
|
await this.dataGatheringQueue.add( |
|
|
|
await this.dataGatheringService.addJobToQueue( |
|
|
|
GATHER_ASSET_PROFILE_PROCESS, |
|
|
|
{ |
|
|
|
dataSource, |
|
|
|
symbol |
|
|
|
}, |
|
|
|
{ |
|
|
|
attempts: 20, |
|
|
|
backoff: { |
|
|
|
delay: ms('1 minute'), |
|
|
|
type: 'exponential' |
|
|
|
}, |
|
|
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH |
|
|
|
} |
|
|
|
GATHER_ASSET_PROFILE_PROCESS_OPTIONS |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -176,20 +156,13 @@ export class AdminController { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
await this.dataGatheringQueue.add( |
|
|
|
await this.dataGatheringService.addJobToQueue( |
|
|
|
GATHER_ASSET_PROFILE_PROCESS, |
|
|
|
{ |
|
|
|
dataSource, |
|
|
|
symbol |
|
|
|
}, |
|
|
|
{ |
|
|
|
attempts: 20, |
|
|
|
backoff: { |
|
|
|
delay: ms('1 minute'), |
|
|
|
type: 'exponential' |
|
|
|
}, |
|
|
|
priority: DATA_GATHERING_QUEUE_PRIORITY_HIGH |
|
|
|
} |
|
|
|
GATHER_ASSET_PROFILE_PROCESS_OPTIONS |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|