Browse Source
Feature/expose PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL environment variable (#7221 )
* Expose PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_REMOVE_ON_FAIL environment variable
* Update changelog
pull/7234/head
Thomas Kaul
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with
36 additions and
21 deletions
CHANGELOG.md
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-buy.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur-in-base-currency-eur.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-cash.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-jnug-buy-and-sell-and-buy-and-sell.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-and-sell.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-no-orders.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-valuable.spec.ts
apps/api/src/services/configuration/configuration.service.ts
apps/api/src/services/interfaces/environment.interface.ts
apps/api/src/services/queues/portfolio-snapshot/portfolio-snapshot.service.ts
@ -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`
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -87,7 +87,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -77,7 +77,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -75,7 +75,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -125,7 +125,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
portfolioCalculatorFactory = new PortfolioCalculatorFactory (
configurationService ,
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -77,7 +77,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -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 ,
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -60,7 +60,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -78,7 +78,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -65,7 +65,7 @@ describe('PortfolioCalculator', () => {
null
) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null ) ;
portfolioSnapshotService = new PortfolioSnapshotService ( null , null ) ;
redisCacheService = new RedisCacheService ( null , null ) ;
@ -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
} ) ,
@ -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 ;
@ -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 ) {