Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/expose PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL environment variable (#7221)
Thomas Kauleedb556c06ae
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e13ae4176b..227ced8077 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## Unreleased+### Added++- Exposed the `PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL` environment variable to control the removal of failed jobs in the portfolio snapshot computation queue+### Changed- Upgraded `stripe` from version `21.0.1` to `22.2.3`diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-buy.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-buy.spec.tsindex 9a93d0419e..f21418cb4d 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-buy.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-buy.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.tsindex c876d0db13..e2cba2e61f 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.tsindex ae921d6d9f..fa397de468 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.tsindex 6207f1417d..db44fe0ae1 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur-in-base-currency-eur.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur-in-base-currency-eur.spec.tsindex 774c1d2f62..1afd9225d2 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur-in-base-currency-eur.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur-in-base-currency-eur.spec.ts@@ -87,7 +87,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.tsindex 0553563253..0e5750166b 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts@@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.tsindex 11765fc49f..1e556735d2 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts@@ -77,7 +77,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.tsindex 6a45f79c61..9d84540e3e 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts@@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.tsindex 64882061f3..0916e18a49 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts@@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.tsindex 2d85330a3c..7774ee6291 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts@@ -125,7 +125,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);portfolioCalculatorFactory = new PortfolioCalculatorFactory(configurationService,diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.tsindex a3fbc07581..b55c94b2be 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.tsindex 122a9aaedc..bb61d637e7 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts@@ -77,7 +77,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-jnug-buy-and-sell-and-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-jnug-buy-and-sell-and-buy-and-sell.spec.tsindex d5b22e864c..88afc971dd 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-jnug-buy-and-sell-and-buy-and-sell.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-jnug-buy-and-sell-and-buy-and-sell.spec.ts@@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.tsindex acbf6a66bb..4f20585131 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-and-sell.spec.tsindex baa6ae1ede..36d1ea1ece 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-and-sell.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-and-sell.spec.ts@@ -60,7 +60,7 @@ describe('PortfolioCalculator', () => {null,null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);portfolioCalculatorFactory = new PortfolioCalculatorFactory(configurationService,diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.tsindex e7eff66822..c50ef2b34e 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-no-orders.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-no-orders.spec.tsindex 6c47af7caf..30ebaa8c46 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-no-orders.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-no-orders.spec.ts@@ -60,7 +60,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.tsindex 3034e3a1f9..cdfc78906f 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts@@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.tsindex c79fdef587..2cd754c82d 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts@@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.tsindex e518a59945..1d6cee0fa6 100644--- a/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts+++ b/apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts@@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {null);- portfolioSnapshotService = new PortfolioSnapshotService(null);+ portfolioSnapshotService = new PortfolioSnapshotService(null, null);redisCacheService = new RedisCacheService(null, null);diff --git a/apps/api/src/services/configuration/configuration.service.ts b/apps/api/src/services/configuration/configuration.service.tsindex 703a90c3a5..c96ccd9464 100644--- a/apps/api/src/services/configuration/configuration.service.ts+++ b/apps/api/src/services/configuration/configuration.service.ts@@ -96,6 +96,9 @@ export class ConfigurationService {PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_CONCURRENCY: num({default: DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_CONCURRENCY}),+ PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL: bool({+ default: true+ }),PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT: num({default: DEFAULT_PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT}),diff --git a/apps/api/src/services/interfaces/environment.interface.ts b/apps/api/src/services/interfaces/environment.interface.tsindex 11bdeabf60..89463e2016 100644--- a/apps/api/src/services/interfaces/environment.interface.ts+++ b/apps/api/src/services/interfaces/environment.interface.ts@@ -47,6 +47,7 @@ export interface Environment extends CleanedEnvAccessors {PROCESSOR_GATHER_HISTORICAL_MARKET_DATA_CONCURRENCY: number;PROCESSOR_GATHER_STATISTICS_CONCURRENCY: number;PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_CONCURRENCY: number;+ PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL: boolean;PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_TIMEOUT: number;REDIS_DB: number;REDIS_HOST: string;diff --git a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.ts b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.tsindex d7449a9ccc..99fa5aca29 100644--- a/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.ts+++ b/apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.ts@@ -1,3 +1,4 @@+import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service';import { PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE } from '@ghostfolio/common/config';import { InjectQueue } from '@nestjs/bull';@@ -9,6 +10,7 @@ import { PortfolioSnapshotQueueJob } from './interfaces/portfolio-snapshot-queue@Injectable()export class PortfolioSnapshotService {public constructor(+ private readonly configurationService: ConfigurationService,@InjectQueue(PORTFOLIO_SNAPSHOT_COMPUTATION_QUEUE)private readonly portfolioSnapshotQueue: Queue) {}@@ -22,7 +24,12 @@ export class PortfolioSnapshotService {name: string;opts?: JobOptions;}) {- return this.portfolioSnapshotQueue.add(name, data, opts);+ return this.portfolioSnapshotQueue.add(name, data, {+ ...opts,+ removeOnFail: this.configurationService.get(+ 'PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL'+ )+ });}public async getJob(jobId: string) {