Browse Source

Clean up

pull/3725/head
Thomas Kaul 12 months ago
parent
commit
c2392f929a
  1. 13
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 4
      apps/api/src/services/portfolio-snapshot/portfolio-snapshot.module.ts
  3. 6
      apps/api/src/services/portfolio-snapshot/portfolio-snapshot.service.ts
  4. 9
      libs/common/src/lib/config.ts

13
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -14,7 +14,9 @@ import { PortfolioSnapshotService } from '@ghostfolio/api/services/portfolio-sna
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper';
import {
PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,
PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS
PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS,
PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_HIGH,
PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_LOW
} from '@ghostfolio/common/config';
import {
DATE_FORMAT,
@ -1063,14 +1065,13 @@ export abstract class PortfolioCalculator {
name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,
opts: {
...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS,
jobId
// priority
jobId,
priority: PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_LOW
}
});
}
} else {
// Wait for computation
// TODO
const job = await this.portfolioSnapshotService.addJobToQueue({
data: {
filters: this.filters,
@ -1080,8 +1081,8 @@ export abstract class PortfolioCalculator {
name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,
opts: {
...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS,
jobId
// priority
jobId,
priority: PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_HIGH
}
});

4
apps/api/src/services/portfolio-snapshot/portfolio-snapshot.module.ts

@ -20,10 +20,6 @@ import { PortfolioSnapshotProcessor } from './portfolio-snapshot.processor';
@Module({
imports: [
BullModule.registerQueue({
// limiter: {
// duration: ms('4 seconds'),
// max: 1
// },
name: PORTFOLIO_SNAPSHOT_QUEUE
}),
ConfigurationModule,

6
apps/api/src/services/portfolio-snapshot/portfolio-snapshot.service.ts

@ -24,10 +24,4 @@ export class PortfolioSnapshotService {
}) {
return this.portfolioSnapshotQueue.add(name, data, opts);
}
// public async addJobsToQueue(
// jobs: { data: IPortfolioSnapshotQueueJob; name: string; opts?: JobOptions }[]
// ) {
// return this.portfolioSnapshotQueue.addBulk(jobs);
// }
}

9
libs/common/src/lib/config.ts

@ -41,6 +41,8 @@ export const DATA_GATHERING_QUEUE_PRIORITY_MEDIUM = Math.round(
);
export const PORTFOLIO_SNAPSHOT_QUEUE = 'PORTFOLIO_SNAPSHOT_QUEUE';
export const PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_HIGH = 1;
export const PORTFOLIO_SNAPSHOT_QUEUE_PRIORITY_LOW = Number.MAX_SAFE_INTEGER;
export const DEFAULT_CURRENCY = 'USD';
export const DEFAULT_DATE_FORMAT_MONTH_YEAR = 'MMM yyyy';
@ -78,6 +80,7 @@ export const GATHER_ASSET_PROFILE_PROCESS_OPTIONS: JobOptions = {
},
removeOnComplete: true
};
export const GATHER_HISTORICAL_MARKET_DATA_PROCESS_JOB_NAME =
'GATHER_HISTORICAL_MARKET_DATA';
export const GATHER_HISTORICAL_MARKET_DATA_PROCESS_JOB_OPTIONS: JobOptions = {
@ -88,13 +91,9 @@ export const GATHER_HISTORICAL_MARKET_DATA_PROCESS_JOB_OPTIONS: JobOptions = {
},
removeOnComplete: true
};
export const PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME = 'PORTFOLIO';
export const PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS: JobOptions = {
// attempts: 12,
// backoff: {
// delay: ms('1 minute'),
// type: 'exponential'
// },
removeOnComplete: true
};

Loading…
Cancel
Save