|
|
|
@ -1,14 +1,15 @@ |
|
|
|
import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; |
|
|
|
import { SubscriptionService } from '@ghostfolio/api/app/subscription/subscription.service'; |
|
|
|
import { UserService } from '@ghostfolio/api/app/user/user.service'; |
|
|
|
import { encodeDataSource } from '@ghostfolio/api/helper/data-source.helper'; |
|
|
|
import { BenchmarkService } from '@ghostfolio/api/services/benchmark/benchmark.service'; |
|
|
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|
|
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider/data-provider.service'; |
|
|
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; |
|
|
|
import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; |
|
|
|
import { PropertyService } from '@ghostfolio/api/services/property/property.service'; |
|
|
|
import { |
|
|
|
DEFAULT_CURRENCY, |
|
|
|
ghostfolioFearAndGreedIndexSymbolStocks, |
|
|
|
PROPERTY_COUNTRIES_OF_SUBSCRIBERS, |
|
|
|
PROPERTY_DEMO_USER_ID, |
|
|
|
PROPERTY_DOCKER_HUB_PULLS, |
|
|
|
@ -23,6 +24,7 @@ import { permissions } from '@ghostfolio/common/permissions'; |
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { JwtService } from '@nestjs/jwt'; |
|
|
|
import { MarketData } from '@prisma/client'; |
|
|
|
import { subDays } from 'date-fns'; |
|
|
|
import { isNil } from 'lodash'; |
|
|
|
|
|
|
|
@ -36,6 +38,7 @@ export class InfoService { |
|
|
|
private readonly dataProviderService: DataProviderService, |
|
|
|
private readonly exchangeRateDataService: ExchangeRateDataService, |
|
|
|
private readonly jwtService: JwtService, |
|
|
|
private readonly marketDataService: MarketDataService, |
|
|
|
private readonly propertyService: PropertyService, |
|
|
|
private readonly redisCacheService: RedisCacheService, |
|
|
|
private readonly subscriptionService: SubscriptionService, |
|
|
|
@ -45,6 +48,7 @@ export class InfoService { |
|
|
|
public async get(): Promise<InfoItem> { |
|
|
|
const info: Partial<InfoItem> = {}; |
|
|
|
let isReadOnlyMode: boolean; |
|
|
|
let latestFearAndGreedStocksMarketDataPromise: Promise<MarketData>; |
|
|
|
|
|
|
|
const globalPermissions: string[] = []; |
|
|
|
|
|
|
|
@ -61,16 +65,12 @@ export class InfoService { |
|
|
|
} |
|
|
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) { |
|
|
|
const fearAndGreedIndexDataSource = |
|
|
|
this.dataProviderService.getDataSourceForFearAndGreedIndexStocks(); |
|
|
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
|
info.fearAndGreedDataSource = encodeDataSource( |
|
|
|
fearAndGreedIndexDataSource |
|
|
|
); |
|
|
|
} else { |
|
|
|
info.fearAndGreedDataSource = fearAndGreedIndexDataSource; |
|
|
|
} |
|
|
|
latestFearAndGreedStocksMarketDataPromise = |
|
|
|
this.marketDataService.getLatest({ |
|
|
|
dataSource: |
|
|
|
this.dataProviderService.getDataSourceForFearAndGreedIndexStocks(), |
|
|
|
symbol: ghostfolioFearAndGreedIndexSymbolStocks |
|
|
|
}); |
|
|
|
|
|
|
|
globalPermissions.push(permissions.enableFearAndGreedIndex); |
|
|
|
} |
|
|
|
@ -102,12 +102,14 @@ export class InfoService { |
|
|
|
benchmarks, |
|
|
|
demoAuthToken, |
|
|
|
isUserSignupEnabled, |
|
|
|
latestFearAndGreedStocksMarketData, |
|
|
|
statistics, |
|
|
|
subscriptionOffer |
|
|
|
] = await Promise.all([ |
|
|
|
this.benchmarkService.getBenchmarkAssetProfiles(), |
|
|
|
this.getDemoAuthToken(), |
|
|
|
this.propertyService.isUserSignupEnabled(), |
|
|
|
latestFearAndGreedStocksMarketDataPromise, |
|
|
|
this.getStatistics(), |
|
|
|
this.subscriptionService.getSubscriptionOffer({ key: 'default' }) |
|
|
|
]); |
|
|
|
@ -125,7 +127,9 @@ export class InfoService { |
|
|
|
statistics, |
|
|
|
subscriptionOffer, |
|
|
|
baseCurrency: DEFAULT_CURRENCY, |
|
|
|
currencies: this.exchangeRateDataService.getCurrencies() |
|
|
|
currencies: this.exchangeRateDataService.getCurrencies(), |
|
|
|
fearAndGreedStocksMarketPrice: |
|
|
|
latestFearAndGreedStocksMarketData?.marketPrice |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|