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
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
36 additions and
27 deletions
-
CHANGELOG.md
-
apps/api/src/app/admin/admin.service.ts
|
|
@ -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`) |
|
|
|
|
|
|
|
|
|
@ -108,8 +108,7 @@ export class AdminService { |
|
|
|
} |
|
|
|
|
|
|
|
public async get(): Promise<AdminData> { |
|
|
|
return { |
|
|
|
exchangeRates: this.exchangeRateDataService |
|
|
|
const exchangeRates = this.exchangeRateDataService |
|
|
|
.getCurrencies() |
|
|
|
.filter((currency) => { |
|
|
|
return currency !== DEFAULT_CURRENCY; |
|
|
@ -132,10 +131,19 @@ export class AdminService { |
|
|
|
currency |
|
|
|
) |
|
|
|
}; |
|
|
|
}), |
|
|
|
settings: await this.propertyService.get(), |
|
|
|
transactionCount: await this.prismaService.order.count(), |
|
|
|
userCount: await this.prismaService.user.count(), |
|
|
|
}); |
|
|
|
|
|
|
|
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 |
|
|
|
}; |
|
|
|
} |
|
|
|