Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Task/improve performance of historical data count in market data table of admin control (#8214)
Thomas Kaul8eab609921dd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9a0ff16c19..3a6959f512 100644--- a/CHANGELOG.md+++ b/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### Addeddiff --git a/apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts b/apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.tsindex fc0d97fa62..a104fd48cc 100644--- a/apps/api/src/app/endpoints/asset-profiles/asset-profiles.service.ts+++ b/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,