@@ -30,7 +30,7 @@ import type { Granularity, UserWithSettings } from '@ghostfolio/common/types';
30
30
import { Inject , Injectable , Logger } from '@nestjs/common' ;
31
31
import { DataSource , MarketData , SymbolProfile } from '@prisma/client' ;
32
32
import { Big } from 'big.js' ;
33
- import { eachDayOfInterval , format , isValid } from 'date-fns' ;
33
+ import { eachDayOfInterval , format , isBefore , isValid } from 'date-fns' ;
34
34
import { groupBy , isEmpty , isNumber , uniqWith } from 'lodash' ;
35
35
import ms from 'ms' ;
36
36
@@ -154,9 +154,22 @@ export class DataProviderService {
154
154
return DataSource [ this . configurationService . get ( 'DATA_SOURCE_IMPORT' ) ] ;
155
155
}
156
156
157
- public async getDataSources ( ) : Promise < DataSource [ ] > {
157
+ public async getDataSources ( {
158
+ user
159
+ } : {
160
+ user : UserWithSettings ;
161
+ } ) : Promise < DataSource [ ] > {
162
+ let dataSourcesKey : 'DATA_SOURCES' | 'DATA_SOURCES_LEGACY' = 'DATA_SOURCES' ;
163
+
164
+ if (
165
+ isBefore ( user . createdAt , new Date ( '2025-03-23' ) ) &&
166
+ this . configurationService . get ( 'DATA_SOURCES_LEGACY' ) ?. length > 0
167
+ ) {
168
+ dataSourcesKey = 'DATA_SOURCES_LEGACY' ;
169
+ }
170
+
158
171
const dataSources : DataSource [ ] = this . configurationService
159
- . get ( 'DATA_SOURCES' )
172
+ . get ( dataSourcesKey )
160
173
. map ( ( dataSource ) => {
161
174
return DataSource [ dataSource ] ;
162
175
} ) ;
@@ -608,7 +621,7 @@ export class DataProviderService {
608
621
return { items : lookupItems } ;
609
622
}
610
623
611
- const dataSources = await this . getDataSources ( ) ;
624
+ const dataSources = await this . getDataSources ( { user } ) ;
612
625
613
626
const dataProviderServices = dataSources . map ( ( dataSource ) => {
614
627
return this . getDataProvider ( DataSource [ dataSource ] ) ;
0 commit comments