Browse Source

Refactoring

pull/5434/head
Thomas Kaul 4 months ago
parent
commit
d9e19537fc
  1. 20
      apps/api/src/app/admin/admin.service.ts
  2. 13
      apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts

20
apps/api/src/app/admin/admin.service.ts

@ -136,11 +136,13 @@ export class AdminService {
public async get(): Promise<AdminData> { public async get(): Promise<AdminData> {
const dataSources = Object.values(DataSource); const dataSources = Object.values(DataSource);
const [settings, transactionCount, userCount] = await Promise.all([ const [enabledDataSources, settings, transactionCount, userCount] =
this.propertyService.get(), await Promise.all([
this.prismaService.order.count(), this.dataProviderService.getDataSources(),
this.countUsersWithAnalytics() this.propertyService.get(),
]); this.prismaService.order.count(),
this.countUsersWithAnalytics()
]);
const dataProviders = ( const dataProviders = (
await Promise.all( 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 const dataProviderInfo = this.dataProviderService
.getDataProvider(dataSource) .getDataProvider(dataSource)
.getDataProviderInfo(); .getDataProviderInfo();

13
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( .pipe(
switchMap(() => { switchMap(() => {
// Gather historical data for the currency
return this.adminService.gatherSymbol({ return this.adminService.gatherSymbol({
dataSource: this.exchangeRateDataSource, dataSource: this.exchangeRateDataSource,
symbol: `${currency}${DEFAULT_CURRENCY}` symbol: `${DEFAULT_CURRENCY}${currency}`
}); });
}), }),
takeUntil(this.unsubscribeSubject) takeUntil(this.unsubscribeSubject)
@ -186,14 +185,14 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
this.adminService this.adminService
.fetchAdminData() .fetchAdminData()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ settings, dataProviders }) => { .subscribe(({ dataProviders, settings }) => {
this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[]; this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[];
const exchangeRateProvider = dataProviders.find( const { dataSource } = dataProviders.find(({ useForExchangeRates }) => {
(provider) => provider.useForExchangeRates return useForExchangeRates;
); });
this.exchangeRateDataSource = exchangeRateProvider?.dataSource; this.exchangeRateDataSource = dataSource;
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });

Loading…
Cancel
Save