Browse Source

Optimize by using Promise.all()

pull/3741/head
Thomas Kaul 12 months ago
parent
commit
ee612e7988
  1. 20
      apps/api/src/app/admin/admin.service.ts

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

@ -108,8 +108,7 @@ export class AdminService {
} }
public async get(): Promise<AdminData> { public async get(): Promise<AdminData> {
return { const exchangeRates = this.exchangeRateDataService
exchangeRates: this.exchangeRateDataService
.getCurrencies() .getCurrencies()
.filter((currency) => { .filter((currency) => {
return currency !== DEFAULT_CURRENCY; return currency !== DEFAULT_CURRENCY;
@ -132,10 +131,19 @@ export class AdminService {
currency currency
) )
}; };
}), });
settings: await this.propertyService.get(),
transactionCount: await this.prismaService.order.count(), const [settings, transactionCount, userCount] = await Promise.all([
userCount: await this.prismaService.user.count(), this.propertyService.get(),
this.prismaService.order.count(),
this.prismaService.user.count()
]);
return {
exchangeRates,
settings,
transactionCount,
userCount,
version: environment.version version: environment.version
}; };
} }

Loading…
Cancel
Save