Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/optimize admin control panel endpoint using promise.all (#3741)
Thomas Kaul6db881b08f49
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex afc0dcc58b..e4d92ad12a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed- Optimized the asynchronous operations using `Promise.all()` in the info service+- Optimized the asynchronous operations using `Promise.all()` in the admin control panel endpoint- Extracted the users from the admin control panel endpoint to a dedicated endpoint- Improved the language localization for Italian (`it`)diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.tsindex 3f52742854..143d5c1ca3 100644--- a/apps/api/src/app/admin/admin.service.ts+++ b/apps/api/src/app/admin/admin.service.ts@@ -108,34 +108,42 @@ export class AdminService {}public async get(): Promise<AdminData> {- return {- exchangeRates: this.exchangeRateDataService- .getCurrencies()- .filter((currency) => {- return currency !== DEFAULT_CURRENCY;- })- .map((currency) => {- const label1 = DEFAULT_CURRENCY;- const label2 = currency;+ const exchangeRates = this.exchangeRateDataService+ .getCurrencies()+ .filter((currency) => {+ return currency !== DEFAULT_CURRENCY;+ })+ .map((currency) => {+ const label1 = DEFAULT_CURRENCY;+ const label2 = currency;- return {- label1,- label2,- dataSource:- DataSource[- this.configurationService.get('DATA_SOURCE_EXCHANGE_RATES')- ],- symbol: `${label1}${label2}`,- value: this.exchangeRateDataService.toCurrency(- 1,- DEFAULT_CURRENCY,- currency- )- };- }),- settings: await this.propertyService.get(),- transactionCount: await this.prismaService.order.count(),- userCount: await this.prismaService.user.count(),+ return {+ label1,+ label2,+ dataSource:+ DataSource[+ this.configurationService.get('DATA_SOURCE_EXCHANGE_RATES')+ ],+ symbol: `${label1}${label2}`,+ value: this.exchangeRateDataService.toCurrency(+ 1,+ DEFAULT_CURRENCY,+ currency+ )+ };+ });++ const [settings, transactionCount, userCount] = await Promise.all([+ this.propertyService.get(),+ this.prismaService.order.count(),+ this.prismaService.user.count()+ ]);++ return {+ exchangeRates,+ settings,+ transactionCount,+ userCount,version: environment.version};}