Skip to content

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

Feature/respect watcher count in delete asset profile checkbox (#4609)

Thomas Kaul862de91e7b21
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8f9ebbb71..db9ccf9bf5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the error message of the currency code validation
- Tightened the currency code validation by requiring uppercase letters
+- Respected the watcher count for the delete asset profiles checkbox in the historical market data table of the admin control panel
- Improved the language localization for Français (`fr`)
- Upgraded `ngx-skeleton-loader` from version `10.0.0` to `11.0.0`
- Upgraded `Nx` from version `20.8.0` to `20.8.1`
diff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.ts
index 4cd4abcdb3..e729027048 100644
--- a/apps/api/src/app/admin/admin.service.ts
+++ b/apps/api/src/app/admin/admin.service.ts
@@ -238,7 +238,10 @@ export class AdminService {
where,
select: {
_count: {
- select: { Order: true }
+ select: {
+ Order: true,
+ watchedBy: true
+ }
},
assetClass: true,
assetSubClass: true,
@@ -375,7 +378,9 @@ export class AdminService {
sectorsCount,
activitiesCount: _count.Order,
date: Order?.[0]?.date,
- isUsedByUsersWithSubscription: await isUsedByUsersWithSubscription
+ isUsedByUsersWithSubscription:
+ await isUsedByUsersWithSubscription,
+ watchedByCount: _count.watchedBy
};
}
)
@@ -752,7 +757,8 @@ export class AdminService {
id: undefined,
isActive: true,
name: symbol,
- sectorsCount: 0
+ sectorsCount: 0,
+ watchedByCount: 0
};
}
);
diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.html b/apps/client/src/app/components/admin-market-data/admin-market-data.html
index 6ba8f18109..bfa6d550e9 100644
--- a/apps/client/src/app/components/admin-market-data/admin-market-data.html
+++ b/apps/client/src/app/components/admin-market-data/admin-market-data.html
@@ -55,7 +55,8 @@
adminMarketDataService.hasPermissionToDeleteAssetProfile({
activitiesCount: element.activitiesCount,
isBenchmark: element.isBenchmark,
- symbol: element.symbol
+ symbol: element.symbol,
+ watchedByCount: element.watchedByCount
})
) {
<mat-checkbox
diff --git a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
index 0e2cb7ef3f..78d4bf9551 100644
--- a/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
+++ b/apps/client/src/app/components/admin-market-data/admin-market-data.service.ts
@@ -72,14 +72,19 @@ export class AdminMarketDataService {
public hasPermissionToDeleteAssetProfile({
activitiesCount,
isBenchmark,
- symbol
- }: Pick<AdminMarketDataItem, 'activitiesCount' | 'isBenchmark' | 'symbol'>) {
+ symbol,
+ watchedByCount
+ }: Pick<
+ AdminMarketDataItem,
+ 'activitiesCount' | 'isBenchmark' | 'symbol' | 'watchedByCount'
+ >) {
return (
activitiesCount === 0 &&
!isBenchmark &&
!isDerivedCurrency(getCurrencyFromSymbol(symbol)) &&
!isRootCurrency(getCurrencyFromSymbol(symbol)) &&
- !symbol.startsWith(ghostfolioScraperApiSymbolPrefix)
+ !symbol.startsWith(ghostfolioScraperApiSymbolPrefix) &&
+ watchedByCount === 0
);
}
}
diff --git a/libs/common/src/lib/interfaces/admin-market-data.interface.ts b/libs/common/src/lib/interfaces/admin-market-data.interface.ts
index d726724890..953f94e26e 100644
--- a/libs/common/src/lib/interfaces/admin-market-data.interface.ts
+++ b/libs/common/src/lib/interfaces/admin-market-data.interface.ts
@@ -22,4 +22,5 @@ export interface AdminMarketDataItem {
name: string;
sectorsCount: number;
symbol: string;
+ watchedByCount: number;
}