From 608bd82015ca337e7c2dbb9dc16776a18616ea6f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 7 Sep 2024 10:07:00 +0200 Subject: [PATCH] Refactoring --- .../portfolio/calculator/portfolio-calculator.ts | 12 ++++++------ .../portfolio-snapshot.processor.ts | 13 ++++++++----- libs/common/src/lib/config.ts | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index 73cf2ae8c..53cc62833 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -14,8 +14,8 @@ import { PortfolioSnapshotService } from '@ghostfolio/api/services/portfolio-sna import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'; import { CACHE_TTL_INFINITE } from '@ghostfolio/common/config'; import { - PORTFOLIO_PROCESS_JOB_NAME, - PORTFOLIO_PROCESS_JOB_OPTIONS + PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, + PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS } from '@ghostfolio/common/config'; import { DATE_FORMAT, @@ -1082,9 +1082,9 @@ export abstract class PortfolioCalculator { data: { userId: this.userId }, - name: PORTFOLIO_PROCESS_JOB_NAME, + name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, opts: { - ...PORTFOLIO_PROCESS_JOB_OPTIONS + ...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS // jobId // priority } @@ -1098,9 +1098,9 @@ export abstract class PortfolioCalculator { data: { userId: this.userId }, - name: PORTFOLIO_PROCESS_JOB_NAME, + name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, opts: { - ...PORTFOLIO_PROCESS_JOB_OPTIONS + ...PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS // jobId // priority } diff --git a/apps/api/src/services/portfolio-snapshot/portfolio-snapshot.processor.ts b/apps/api/src/services/portfolio-snapshot/portfolio-snapshot.processor.ts index d7eb1db60..737b7b5fc 100644 --- a/apps/api/src/services/portfolio-snapshot/portfolio-snapshot.processor.ts +++ b/apps/api/src/services/portfolio-snapshot/portfolio-snapshot.processor.ts @@ -1,5 +1,5 @@ import { - PORTFOLIO_PROCESS_JOB_NAME, + PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME, PORTFOLIO_SNAPSHOT_QUEUE } from '@ghostfolio/common/config'; @@ -16,14 +16,14 @@ import { IPortfolioSnapshotQueueJob } from './interfaces/portfolio-snapshot-queu export class PortfolioSnapshotProcessor { public constructor() {} - @Process({ concurrency: 1, name: PORTFOLIO_PROCESS_JOB_NAME }) + @Process({ concurrency: 1, name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME }) public async calculatePortfolioSnapshot( job: Job ) { try { Logger.log( `Portfolio snapshot calculation of user ${job.data.userId} has been started`, - `PortfolioProcessor (${PORTFOLIO_PROCESS_JOB_NAME})` + `PortfolioProcessor (${PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME})` ); // TODO: Do something @@ -31,10 +31,13 @@ export class PortfolioSnapshotProcessor { Logger.log( `Portfolio snapshot calculation of user ${job.data.userId} has been completed`, - `PortfolioProcessor (${PORTFOLIO_PROCESS_JOB_NAME})` + `PortfolioProcessor (${PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME})` ); } catch (error) { - Logger.error(error, `PortfolioProcessor (${PORTFOLIO_PROCESS_JOB_NAME})`); + Logger.error( + error, + `PortfolioProcessor (${PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME})` + ); throw new Error(error); } diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index 6161c2634..7639ca7cd 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -88,8 +88,8 @@ export const GATHER_HISTORICAL_MARKET_DATA_PROCESS_JOB_OPTIONS: JobOptions = { }, removeOnComplete: true }; -export const PORTFOLIO_PROCESS_JOB_NAME = 'PORTFOLIO'; -export const PORTFOLIO_PROCESS_JOB_OPTIONS: JobOptions = { +export const PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME = 'PORTFOLIO'; +export const PORTFOLIO_SNAPSHOT_PROCESS_JOB_OPTIONS: JobOptions = { // attempts: 12, // backoff: { // delay: ms('1 minute'),