Browse Source

Task/improve performance of historical data count in market data table of admin control (#8214)

* Improve performance of historical data count

* Update changelog
pull/8288/head
Thomas Kaul 5 days ago
committed by GitHub
parent
commit
8eab609921
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 36
      apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts

6
CHANGELOG.md

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Improved the performance of the historical market data table of the admin control panel by counting the market data per asset profile
## 3.91.0 - 2026-10-23
### Added

36
apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts

@ -256,11 +256,6 @@ export class AssetProfilesService {
return type;
});
const marketDataItems = await this.prismaService.marketData.groupBy({
_count: true,
by: ['dataSource', 'symbol']
});
if (filterByAssetSubClass) {
where.assetSubClass = AssetSubClass[filterByAssetSubClass.id];
}
@ -378,13 +373,12 @@ export class AssetProfilesService {
await this.marketDataService.getLatest({ dataSource, symbol })
)?.marketPrice;
const marketDataItemCount =
marketDataItems.find((marketDataItem) => {
return (
marketDataItem.dataSource === dataSource &&
marketDataItem.symbol === symbol
);
})?._count ?? 0;
const marketDataItemCount = await this.prismaService.marketData.count({
where: {
dataSource,
symbol
}
});
const sectorsCount = sectors ? Object.keys(sectors).length : 0;
@ -521,11 +515,6 @@ export class AssetProfilesService {
private async getAssetProfilesForCurrencies(): Promise<AssetProfilesResponse> {
const currencyPairs = this.exchangeRateDataService.getCurrencyPairs();
const marketDataItems = await this.prismaService.marketData.groupBy({
_count: true,
by: ['dataSource', 'symbol']
});
const assetProfilePromises: Promise<AssetProfileItem>[] = currencyPairs.map(
async ({ dataSource, symbol }) => {
let activitiesCount: EnhancedAssetProfile['activitiesCount'] = 0;
@ -542,13 +531,12 @@ export class AssetProfilesService {
await this.marketDataService.getLatest({ dataSource, symbol })
)?.marketPrice;
const marketDataItemCount =
marketDataItems.find((marketDataItem) => {
return (
marketDataItem.dataSource === dataSource &&
marketDataItem.symbol === symbol
);
})?._count ?? 0;
const marketDataItemCount = await this.prismaService.marketData.count({
where: {
dataSource,
symbol
}
});
return {
activitiesCount,

Loading…
Cancel
Save