Browse Source

Merge 420bcb1e55 into 806d83f453

pull/8060/merge
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
51dada6e33
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 83
      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/), 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). 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 loading only the latest market price per asset profile
## 3.80.2 - 2026-10-06 ## 3.80.2 - 2026-10-06
### Added ### Added

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

@ -334,37 +334,6 @@ export class AssetProfilesService {
const symbolProfiles = symbolProfileResult[0]; const symbolProfiles = symbolProfileResult[0];
let count = symbolProfileResult[1]; let count = symbolProfileResult[1];
const lastMarketPrices = await this.prismaService.marketData.findMany({
distinct: ['dataSource', 'symbol'],
orderBy: { date: 'desc' },
select: {
dataSource: true,
marketPrice: true,
symbol: true
},
where: {
dataSource: {
in: symbolProfiles.map(({ dataSource }) => {
return dataSource;
})
},
symbol: {
in: symbolProfiles.map(({ symbol }) => {
return symbol;
})
}
}
});
const lastMarketPriceMap = new Map<string, number>();
for (const { dataSource, marketPrice, symbol } of lastMarketPrices) {
lastMarketPriceMap.set(
getAssetProfileIdentifier({ dataSource, symbol }),
marketPrice
);
}
const dataProviderInfoMap = new Map<DataSource, DataProviderInfo>( const dataProviderInfoMap = new Map<DataSource, DataProviderInfo>(
[ [
...new Set( ...new Set(
@ -405,9 +374,9 @@ export class AssetProfilesService {
const countriesCount = countries ? Object.keys(countries).length : 0; const countriesCount = countries ? Object.keys(countries).length : 0;
const lastMarketPrice = lastMarketPriceMap.get( const lastMarketPrice = (
getAssetProfileIdentifier({ dataSource, symbol }) await this.marketDataService.getLatest({ dataSource, symbol })
); )?.marketPrice;
const marketDataItemCount = const marketDataItemCount =
marketDataItems.find((marketDataItem) => { marketDataItems.find((marketDataItem) => {
@ -552,42 +521,10 @@ export class AssetProfilesService {
private async getAssetProfilesForCurrencies(): Promise<AssetProfilesResponse> { private async getAssetProfilesForCurrencies(): Promise<AssetProfilesResponse> {
const currencyPairs = this.exchangeRateDataService.getCurrencyPairs(); const currencyPairs = this.exchangeRateDataService.getCurrencyPairs();
const [lastMarketPrices, marketDataItems] = await Promise.all([ const marketDataItems = await this.prismaService.marketData.groupBy({
this.prismaService.marketData.findMany({ _count: true,
distinct: ['dataSource', 'symbol'], by: ['dataSource', 'symbol']
orderBy: { date: 'desc' }, });
select: {
dataSource: true,
marketPrice: true,
symbol: true
},
where: {
dataSource: {
in: currencyPairs.map(({ dataSource }) => {
return dataSource;
})
},
symbol: {
in: currencyPairs.map(({ symbol }) => {
return symbol;
})
}
}
}),
this.prismaService.marketData.groupBy({
_count: true,
by: ['dataSource', 'symbol']
})
]);
const lastMarketPriceMap = new Map<string, number>();
for (const { dataSource, marketPrice, symbol } of lastMarketPrices) {
lastMarketPriceMap.set(
getAssetProfileIdentifier({ dataSource, symbol }),
marketPrice
);
}
const assetProfilePromises: Promise<AssetProfileItem>[] = currencyPairs.map( const assetProfilePromises: Promise<AssetProfileItem>[] = currencyPairs.map(
async ({ dataSource, symbol }) => { async ({ dataSource, symbol }) => {
@ -601,9 +538,9 @@ export class AssetProfilesService {
await this.activitiesService.getStatisticsByCurrency(currency)); await this.activitiesService.getStatisticsByCurrency(currency));
} }
const lastMarketPrice = lastMarketPriceMap.get( const lastMarketPrice = (
getAssetProfileIdentifier({ dataSource, symbol }) await this.marketDataService.getLatest({ dataSource, symbol })
); )?.marketPrice;
const marketDataItemCount = const marketDataItemCount =
marketDataItems.find((marketDataItem) => { marketDataItems.find((marketDataItem) => {

Loading…
Cancel
Save