Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/fix issue with symbol profile overrides in historical market data table of admin control panel (#4339)

Thomas Kaul69a0de28cd9a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8020def58..ed9e778f66 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Improved the error handling in the `HttpResponseInterceptor`
+- Fixed an issue while using symbol profile overrides in the historical market data table of the admin control panel
- Added missing assets in _Storybook_ setup
## 2.139.1 - 2025-02-15
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index 1421097258..ee79059f9e 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -30,6 +30,7 @@ import {
EnhancedSymbolProfile,
Filter
} from '@ghostfolio/common/interfaces';
+import { Sector } from '@ghostfolio/common/interfaces/sector.interface';
import { MarketDataPreset } from '@ghostfolio/common/types';
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
@@ -259,7 +260,8 @@ export class AdminService {
},
scraperConfiguration: true,
sectors: true,
- symbol: true
+ symbol: true,
+ SymbolProfileOverrides: true
}
}),
this.prismaService.symbolProfile.count({ where })
@@ -313,11 +315,10 @@ export class AdminService {
name,
Order,
sectors,
- symbol
+ symbol,
+ SymbolProfileOverrides
}) => {
- const countriesCount = countries
- ? Object.keys(countries).length
- : 0;
+ let countriesCount = countries ? Object.keys(countries).length : 0;
const lastMarketPrice = lastMarketPriceMap.get(
getAssetProfileIdentifier({ dataSource, symbol })
@@ -331,7 +332,34 @@ export class AdminService {
);
})?._count ?? 0;
- const sectorsCount = sectors ? Object.keys(sectors).length : 0;
+ let sectorsCount = sectors ? Object.keys(sectors).length : 0;
+
+ if (SymbolProfileOverrides) {
+ assetClass = SymbolProfileOverrides.assetClass ?? assetClass;
+ assetSubClass =
+ SymbolProfileOverrides.assetSubClass ?? assetSubClass;
+
+ if (
+ (
+ SymbolProfileOverrides.countries as unknown as Prisma.JsonArray
+ )?.length > 0
+ ) {
+ countriesCount = (
+ SymbolProfileOverrides.countries as unknown as Prisma.JsonArray
+ ).length;
+ }
+
+ name = SymbolProfileOverrides.name ?? name;
+
+ if (
+ (SymbolProfileOverrides.sectors as unknown as Sector[])
+ ?.length > 0
+ ) {
+ sectorsCount = (
+ SymbolProfileOverrides.sectors as unknown as Prisma.JsonArray
+ ).length;
+ }
+ }
return {
assetClass,
diff --git a/apps/api/src/services/symbol-profile/symbol-profile.service.ts b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
index df0526d9fa..0dae63311b 100644
--- a/apps/api/src/services/symbol-profile/symbol-profile.service.ts
+++ b/apps/api/src/services/symbol-profile/symbol-profile.service.ts
@@ -204,8 +204,7 @@ export class SymbolProfileService {
?.length > 0
) {
item.countries = this.getCountries(
- item.SymbolProfileOverrides
- ?.countries as unknown as Prisma.JsonArray
+ item.SymbolProfileOverrides.countries as unknown as Prisma.JsonArray
);
}
@@ -214,22 +213,22 @@ export class SymbolProfileService {
?.length > 0
) {
item.holdings = this.getHoldings(
- item.SymbolProfileOverrides?.holdings as unknown as Prisma.JsonArray
+ item.SymbolProfileOverrides.holdings as unknown as Prisma.JsonArray
);
}
- item.name = item.SymbolProfileOverrides?.name ?? item.name;
+ item.name = item.SymbolProfileOverrides.name ?? item.name;
if (
(item.SymbolProfileOverrides.sectors as unknown as Sector[])?.length >
0
) {
item.sectors = this.getSectors(
- item.SymbolProfileOverrides?.sectors as unknown as Prisma.JsonArray
+ item.SymbolProfileOverrides.sectors as unknown as Prisma.JsonArray
);
}
- item.url = item.SymbolProfileOverrides?.url ?? item.url;
+ item.url = item.SymbolProfileOverrides.url ?? item.url;
delete item.SymbolProfileOverrides;
}