From 7577a452f0b5f042c5dbd0c31e9a79ebe5867ea9 Mon Sep 17 00:00:00 2001 From: Shaunak Das <51281688+shaun-ak@users.noreply.github.com> Date: Sun, 23 Feb 2025 13:20:59 +0530 Subject: [PATCH 1/3] Feature/add activities count to GET user endpoint (#4351) * Add activities count to GET user endpoint * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/user/user.service.ts | 9 +++++++-- libs/common/src/lib/interfaces/user.interface.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eac524907..7fd3aaf6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Extended the export functionality by the tags +- Extended the user endpoint `GET api/v1/user` by the activities count ### Changed diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index dcf9d9404..40bc1b2b5 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -86,6 +86,9 @@ export class UserService { orderBy: { alias: 'asc' }, where: { GranteeUser: { id } } }), + this.prismaService.order.count({ + where: { userId: id } + }), this.prismaService.order.findFirst({ orderBy: { date: 'asc' @@ -96,8 +99,9 @@ export class UserService { ]); const access = userData[0]; - const firstActivity = userData[1]; - let tags = userData[2]; + const activitiesCount = userData[1]; + const firstActivity = userData[2]; + let tags = userData[3]; let systemMessage: SystemMessage; @@ -117,6 +121,7 @@ export class UserService { } return { + activitiesCount, id, permissions, subscription, diff --git a/libs/common/src/lib/interfaces/user.interface.ts b/libs/common/src/lib/interfaces/user.interface.ts index 667e59fd8..84f48d1dc 100644 --- a/libs/common/src/lib/interfaces/user.interface.ts +++ b/libs/common/src/lib/interfaces/user.interface.ts @@ -10,6 +10,7 @@ import { UserSettings } from './user-settings.interface'; export interface User { access: Pick[]; accounts: Account[]; + activitiesCount: number; dateOfFirstActivity: Date; id: string; permissions: string[]; From 190abdf9cc390eefeeee7028cf2eba0c30256303 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 24 Feb 2025 13:53:05 +0100 Subject: [PATCH 2/3] Bugfix/improve numeric comparison of strings in value component (#4330) * Improve numeric comparison of strings * Update changelog --- CHANGELOG.md | 4 ++++ libs/ui/src/lib/value/value.component.html | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd3aaf6b..019bf4b6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgraded `prettier` from version `3.4.2` to `3.5.1` +### Fixed + +- Improved the numeric comparison of strings in the value component + ## 2.140.0 - 2025-02-20 ### Changed diff --git a/libs/ui/src/lib/value/value.component.html b/libs/ui/src/lib/value/value.component.html index a691c54e8..0ead7497e 100644 --- a/libs/ui/src/lib/value/value.component.html +++ b/libs/ui/src/lib/value/value.component.html @@ -10,8 +10,8 @@ > -
+
-
-
+
+
+
-
Date: Mon, 24 Feb 2025 21:54:53 +0100 Subject: [PATCH 3/3] Feature/extend portfolio snapshot by activities count (#4352) * Extend portfolio snapshot by activities count * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/portfolio/calculator/portfolio-calculator.ts | 1 + .../src/app/portfolio/calculator/twr/portfolio-calculator.ts | 3 +++ libs/common/src/lib/models/portfolio-snapshot.ts | 2 ++ 4 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 019bf4b6a..ecbcdc820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Extended the export functionality by the tags +- Extended the portfolio snapshot in the portfolio calculator by the activities count - Extended the user endpoint `GET api/v1/user` by the activities count ### Changed diff --git a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts index 2f8a9f0c9..e9c4fdcce 100644 --- a/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/portfolio-calculator.ts @@ -175,6 +175,7 @@ export abstract class PortfolioCalculator { if (!transactionPoints.length) { return { + activitiesCount: 0, currentValueInBaseCurrency: new Big(0), errors: [], hasErrors: false, diff --git a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts index cf808debb..209a0efd5 100644 --- a/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts +++ b/apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts @@ -101,6 +101,9 @@ export class TWRPortfolioCalculator extends PortfolioCalculator { totalInterestWithCurrencyEffect, totalInvestment, totalInvestmentWithCurrencyEffect, + activitiesCount: this.activities.filter(({ type }) => { + return ['BUY', 'SELL'].includes(type); + }).length, errors: [], historicalData: [], totalLiabilitiesWithCurrencyEffect: new Big(0), diff --git a/libs/common/src/lib/models/portfolio-snapshot.ts b/libs/common/src/lib/models/portfolio-snapshot.ts index 46bd5c18f..d0c4c66e0 100644 --- a/libs/common/src/lib/models/portfolio-snapshot.ts +++ b/libs/common/src/lib/models/portfolio-snapshot.ts @@ -9,6 +9,8 @@ import { Big } from 'big.js'; import { Transform, Type } from 'class-transformer'; export class PortfolioSnapshot { + activitiesCount: number; + @Transform(transformToBig, { toClassOnly: true }) @Type(() => Big) currentValueInBaseCurrency: Big;