Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/expose concurrency of portfolio snapshot calculation as environment variable (#3796)
Thomas Kaule918970feb0d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 180306acdf..52ca01d153 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Improved the usability of the create or update access dialog- Improved the loading indicator of the accounts table+- Exposed the concurrency of the portfolio snapshot calculation as an environment variable (`PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT`)- Improved the language localization for German (`de`)- Improved the language localization for Polish (`pl`)- Upgraded `prisma` from version `5.19.0` to `5.19.1`diff --git a/apps/api/src/services/configuration/configuration.service.ts b/apps/api/src/services/configuration/configuration.service.tsindex 26ef38c0a3..0f92461070 100644--- a/apps/api/src/services/configuration/configuration.service.ts+++ b/apps/api/src/services/configuration/configuration.service.ts@@ -1,6 +1,7 @@import { Environment } from '@ghostfolio/api/services/interfaces/environment.interface';import {CACHE_TTL_NO_CACHE,+ DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT,DEFAULT_ROOT_URL} from '@ghostfolio/common/config';@@ -47,6 +48,9 @@ export class ConfigurationService {MAX_ACTIVITIES_TO_IMPORT: num({ default: Number.MAX_SAFE_INTEGER }),MAX_CHART_ITEMS: num({ default: 365 }),PORT: port({ default: 3333 }),+ PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT: num({+ default: DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT+ }),REDIS_DB: num({ default: 0 }),REDIS_HOST: str({ default: 'localhost' }),REDIS_PASSWORD: str({ default: '' }),diff --git a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.tsindex f8173559ed..b3ef4eb88d 100644--- a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts+++ b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.processor.ts@@ -8,6 +8,7 @@ import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.simport { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';import {CACHE_TTL_INFINITE,+ DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT,PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME,PORTFOLIO_SNAPSHOT_QUEUE} from '@ghostfolio/common/config';@@ -29,7 +30,14 @@ export class PortfolioSnapshotProcessor {private readonly redisCacheService: RedisCacheService) {}- @Process({ concurrency: 1, name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME })+ @Process({+ concurrency: parseInt(+ process.env.PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT ??+ DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT.toString(),+ 10+ ),+ name: PORTFOLIO_SNAPSHOT_PROCESS_JOB_NAME+ })public async calculatePortfolioSnapshot(job: Job<IPortfolioSnapshotQueueJob>) {diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.tsindex 79fdf6d051..6fc5650cce 100644--- a/libs/common/src/lib/config.ts+++ b/libs/common/src/lib/config.ts@@ -48,6 +48,7 @@ export const DEFAULT_CURRENCY = 'USD';export const DEFAULT_DATE_FORMAT_MONTH_YEAR = 'MMM yyyy';export const DEFAULT_LANGUAGE_CODE = 'en';export const DEFAULT_PAGE_SIZE = 50;+export const DEFAULT_PROCESSOR_CONCURRENCY_PORTFOLIO_SNAPSHOT = 1;export const DEFAULT_ROOT_URL = 'https://localhost:4200';// USX is handled separately