From d9e19537fc127d2e19ef5c3858297deccdf750c8 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 6 Sep 2025 09:59:20 +0200 Subject: [PATCH] Refactoring --- apps/api/src/app/admin/admin.service.ts | 20 +++++++++++++------ .../create-asset-profile-dialog.component.ts | 13 ++++++------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts index 50b80df70..2918d9d7d 100644 --- a/apps/api/src/app/admin/admin.service.ts +++ b/apps/api/src/app/admin/admin.service.ts @@ -136,11 +136,13 @@ export class AdminService { public async get(): Promise { const dataSources = Object.values(DataSource); - const [settings, transactionCount, userCount] = await Promise.all([ - this.propertyService.get(), - this.prismaService.order.count(), - this.countUsersWithAnalytics() - ]); + const [enabledDataSources, settings, transactionCount, userCount] = + await Promise.all([ + this.dataProviderService.getDataSources(), + this.propertyService.get(), + this.prismaService.order.count(), + this.countUsersWithAnalytics() + ]); const dataProviders = ( await Promise.all( @@ -152,7 +154,13 @@ export class AdminService { } }); - if (assetProfileCount > 0 || dataSource === 'GHOSTFOLIO') { + const isEnabled = enabledDataSources.includes(dataSource); + + if ( + assetProfileCount > 0 || + dataSource === 'GHOSTFOLIO' || + isEnabled + ) { const dataProviderInfo = this.dataProviderService .getDataProvider(dataSource) .getDataProviderInfo(); diff --git a/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts b/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts index c4b4b0b26..2aa795d09 100644 --- a/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts +++ b/apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts @@ -120,10 +120,9 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy { }) .pipe( switchMap(() => { - // Gather historical data for the currency return this.adminService.gatherSymbol({ dataSource: this.exchangeRateDataSource, - symbol: `${currency}${DEFAULT_CURRENCY}` + symbol: `${DEFAULT_CURRENCY}${currency}` }); }), takeUntil(this.unsubscribeSubject) @@ -186,14 +185,14 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy { this.adminService .fetchAdminData() .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ settings, dataProviders }) => { + .subscribe(({ dataProviders, settings }) => { this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[]; - const exchangeRateProvider = dataProviders.find( - (provider) => provider.useForExchangeRates - ); + const { dataSource } = dataProviders.find(({ useForExchangeRates }) => { + return useForExchangeRates; + }); - this.exchangeRateDataSource = exchangeRateProvider?.dataSource; + this.exchangeRateDataSource = dataSource; this.changeDetectorRef.markForCheck(); });