Feature/optimize admin control panel endpoint using promise.all (#3741)
* Optimize by using Promise.all() * Update changelog
This commit is contained in:
parent
557a0bf808
commit
6db881b08f
@ -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`)
|
||||||
|
|
||||||
|
@ -108,34 +108,42 @@ 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;
|
})
|
||||||
})
|
.map((currency) => {
|
||||||
.map((currency) => {
|
const label1 = DEFAULT_CURRENCY;
|
||||||
const label1 = DEFAULT_CURRENCY;
|
const label2 = currency;
|
||||||
const label2 = currency;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label1,
|
label1,
|
||||||
label2,
|
label2,
|
||||||
dataSource:
|
dataSource:
|
||||||
DataSource[
|
DataSource[
|
||||||
this.configurationService.get('DATA_SOURCE_EXCHANGE_RATES')
|
this.configurationService.get('DATA_SOURCE_EXCHANGE_RATES')
|
||||||
],
|
],
|
||||||
symbol: `${label1}${label2}`,
|
symbol: `${label1}${label2}`,
|
||||||
value: this.exchangeRateDataService.toCurrency(
|
value: this.exchangeRateDataService.toCurrency(
|
||||||
1,
|
1,
|
||||||
DEFAULT_CURRENCY,
|
DEFAULT_CURRENCY,
|
||||||
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…
x
Reference in New Issue
Block a user