Browse Source

Feature/optimize admin control panel endpoint using promise.all (#3741)

* Optimize by using Promise.all()

* Update changelog
pull/3724/head^2
Thomas Kaul 7 months ago
committed by GitHub
parent
commit
6db881b08f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 20
      apps/api/src/app/admin/admin.service.ts

1
CHANGELOG.md

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Optimized the asynchronous operations using `Promise.all()` in the info service - 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 - Extracted the users from the admin control panel endpoint to a dedicated endpoint
- Improved the language localization for Italian (`it`) - Improved the language localization for Italian (`it`)

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