|
@ -29,7 +29,7 @@ import { |
|
|
import { hasRole } from '@ghostfolio/common/permissions'; |
|
|
import { hasRole } from '@ghostfolio/common/permissions'; |
|
|
import type { Granularity, UserWithSettings } from '@ghostfolio/common/types'; |
|
|
import type { Granularity, UserWithSettings } from '@ghostfolio/common/types'; |
|
|
|
|
|
|
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
import { Inject, Injectable, Logger, OnModuleInit } from '@nestjs/common'; |
|
|
import { DataSource, MarketData, SymbolProfile } from '@prisma/client'; |
|
|
import { DataSource, MarketData, SymbolProfile } from '@prisma/client'; |
|
|
import { Big } from 'big.js'; |
|
|
import { Big } from 'big.js'; |
|
|
import { eachDayOfInterval, format, isBefore, isValid } from 'date-fns'; |
|
|
import { eachDayOfInterval, format, isBefore, isValid } from 'date-fns'; |
|
@ -37,7 +37,7 @@ import { groupBy, isEmpty, isNumber, uniqWith } from 'lodash'; |
|
|
import ms from 'ms'; |
|
|
import ms from 'ms'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
export class DataProviderService { |
|
|
export class DataProviderService implements OnModuleInit { |
|
|
private dataProviderMapping: { [dataProviderName: string]: string }; |
|
|
private dataProviderMapping: { [dataProviderName: string]: string }; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
@ -48,11 +48,9 @@ export class DataProviderService { |
|
|
private readonly prismaService: PrismaService, |
|
|
private readonly prismaService: PrismaService, |
|
|
private readonly propertyService: PropertyService, |
|
|
private readonly propertyService: PropertyService, |
|
|
private readonly redisCacheService: RedisCacheService |
|
|
private readonly redisCacheService: RedisCacheService |
|
|
) { |
|
|
) {} |
|
|
this.initialize(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async initialize() { |
|
|
public async onModuleInit() { |
|
|
this.dataProviderMapping = |
|
|
this.dataProviderMapping = |
|
|
((await this.propertyService.getByKey(PROPERTY_DATA_SOURCE_MAPPING)) as { |
|
|
((await this.propertyService.getByKey(PROPERTY_DATA_SOURCE_MAPPING)) as { |
|
|
[dataProviderName: string]: string; |
|
|
[dataProviderName: string]: string; |
|
|