Browse Source

Bugfix/fix issue with value in value redaction interceptor (#1627)

* Fix issue with value in value redaction interceptor

* Fix format of world map

* Update changelog
pull/1639/head
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
6aae0cc1e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 7
      apps/api/src/app/portfolio/portfolio.controller.ts
  3. 8
      apps/api/src/app/portfolio/portfolio.service.ts
  4. 2
      apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.component.ts
  5. 5
      apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
  6. 7
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  7. 5
      apps/client/src/app/pages/public/public-page.component.ts
  8. 1
      apps/client/src/app/pages/public/public-page.html
  9. 28
      apps/client/src/app/services/data.service.ts
  10. 2
      libs/common/src/lib/interfaces/historical-data-item.interface.ts
  11. 3
      libs/common/src/lib/interfaces/portfolio-position.interface.ts
  12. 1
      libs/common/src/lib/interfaces/portfolio-public-details.interface.ts

2
CHANGELOG.md

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the unit format (`%`) in the global heat map component of the public page
- Improved the pricing page - Improved the pricing page
- Upgraded `Node.js` from version `16` to `18` (`Dockerfile`) - Upgraded `Node.js` from version `16` to `18` (`Dockerfile`)
- Upgraded `prisma` from version `4.8.0` to `4.9.0` - Upgraded `prisma` from version `4.8.0` to `4.9.0`
@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed the click of unknown accounts in the portfolio proportion chart component - Fixed the click of unknown accounts in the portfolio proportion chart component
- Fixed an issue with `value` in the value redaction interceptor for the impersonation mode
## 1.229.0 - 2023-01-21 ## 1.229.0 - 2023-01-21

7
apps/api/src/app/portfolio/portfolio.controller.ts

@ -131,7 +131,8 @@ export class PortfolioController {
portfolioPosition.investment / totalInvestment; portfolioPosition.investment / totalInvestment;
portfolioPosition.netPerformance = null; portfolioPosition.netPerformance = null;
portfolioPosition.quantity = null; portfolioPosition.quantity = null;
portfolioPosition.value = portfolioPosition.value / totalValue; portfolioPosition.valueInPercentage =
portfolioPosition.value / totalValue;
} }
for (const [name, { current, original }] of Object.entries(accounts)) { for (const [name, { current, original }] of Object.entries(accounts)) {
@ -322,7 +323,7 @@ export class PortfolioController {
totalInvestment: new Big(totalInvestment) totalInvestment: new Big(totalInvestment)
.div(performanceInformation.performance.totalInvestment) .div(performanceInformation.performance.totalInvestment)
.toNumber(), .toNumber(),
value: new Big(value) valueInPercentage: new Big(value)
.div(performanceInformation.performance.currentValue) .div(performanceInformation.performance.currentValue)
.toNumber() .toNumber()
}; };
@ -437,7 +438,7 @@ export class PortfolioController {
sectors: hasDetails ? portfolioPosition.sectors : [], sectors: hasDetails ? portfolioPosition.sectors : [],
symbol: portfolioPosition.symbol, symbol: portfolioPosition.symbol,
url: portfolioPosition.url, url: portfolioPosition.url,
value: portfolioPosition.value / totalValue valueInPercentage: portfolioPosition.value / totalValue
}; };
} }

8
apps/api/src/app/portfolio/portfolio.service.ts

@ -785,8 +785,8 @@ export class PortfolioService {
historicalDataArray.push({ historicalDataArray.push({
averagePrice: orders[0].unitPrice, averagePrice: orders[0].unitPrice,
date: firstBuyDate, date: firstBuyDate,
quantity: orders[0].quantity, marketPrice: orders[0].unitPrice,
value: orders[0].unitPrice quantity: orders[0].quantity
}); });
} }
@ -815,9 +815,9 @@ export class PortfolioService {
historicalDataArray.push({ historicalDataArray.push({
date, date,
marketPrice,
averagePrice: currentAveragePrice, averagePrice: currentAveragePrice,
quantity: currentQuantity, quantity: currentQuantity
value: marketPrice
}); });
maxPrice = Math.max(marketPrice ?? 0, maxPrice); maxPrice = Math.max(marketPrice ?? 0, maxPrice);

2
apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.component.ts

@ -111,7 +111,7 @@ export class PositionDetailDialog implements OnDestroy, OnInit {
return { return {
date: historicalDataItem.date, date: historicalDataItem.date,
value: historicalDataItem.value value: historicalDataItem.marketPrice
}; };
} }
); );

5
apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts

@ -21,6 +21,7 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { Market } from '@ghostfolio/common/types'; import { Market } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
import { Account, AssetClass, DataSource } from '@prisma/client'; import { Account, AssetClass, DataSource } from '@prisma/client';
import { isNumber } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators'; import { distinctUntilChanged, switchMap, takeUntil } from 'rxjs/operators';
@ -339,7 +340,9 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
dataSource: position.dataSource, dataSource: position.dataSource,
name: position.name, name: position.name,
symbol: prettifySymbol(symbol), symbol: prettifySymbol(symbol),
value: position.value value: isNumber(position.value)
? position.value
: position.valueInPercentage
}; };
} }

7
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -19,7 +19,7 @@ import { DateRange, GroupBy, ToggleOption } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
import { AssetClass, DataSource, SymbolProfile } from '@prisma/client'; import { AssetClass, DataSource, SymbolProfile } from '@prisma/client';
import { differenceInDays } from 'date-fns'; import { differenceInDays } from 'date-fns';
import { sortBy } from 'lodash'; import { isNumber, sortBy } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators'; import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
@ -312,12 +312,13 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
date, date,
netPerformanceInPercentage, netPerformanceInPercentage,
totalInvestment, totalInvestment,
value value,
valueInPercentage
} of chart) { } of chart) {
this.investments.push({ date, investment: totalInvestment }); this.investments.push({ date, investment: totalInvestment });
this.performanceDataItems.push({ this.performanceDataItems.push({
date, date,
value value: isNumber(value) ? value : valueInPercentage
}); });
this.performanceDataItemsInPercentage.push({ this.performanceDataItemsInPercentage.push({
date, date,

5
apps/client/src/app/pages/public/public-page.component.ts

@ -9,6 +9,7 @@ import {
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { Market } from '@ghostfolio/common/types'; import { Market } from '@ghostfolio/common/types';
import { StatusCodes } from 'http-status-codes'; import { StatusCodes } from 'http-status-codes';
import { isNumber } from 'lodash';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { EMPTY, Subject } from 'rxjs'; import { EMPTY, Subject } from 'rxjs';
import { catchError, takeUntil } from 'rxjs/operators'; import { catchError, takeUntil } from 'rxjs/operators';
@ -198,7 +199,9 @@ export class PublicPageComponent implements OnInit {
this.symbols[prettifySymbol(symbol)] = { this.symbols[prettifySymbol(symbol)] = {
name: position.name, name: position.name,
symbol: prettifySymbol(symbol), symbol: prettifySymbol(symbol),
value: position.value value: isNumber(position.value)
? position.value
: position.valueInPercentage
}; };
} }

1
apps/client/src/app/pages/public/public-page.html

@ -77,6 +77,7 @@
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<gf-world-map-chart <gf-world-map-chart
format="{0}%"
[countries]="countries" [countries]="countries"
[isInPercent]="true" [isInPercent]="true"
></gf-world-map-chart> ></gf-world-map-chart>

28
apps/client/src/app/services/data.service.ts

@ -41,7 +41,7 @@ import { AccountWithValue, DateRange, GroupBy } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n'; import { translate } from '@ghostfolio/ui/i18n';
import { DataSource, Order as OrderModel } from '@prisma/client'; import { DataSource, Order as OrderModel } from '@prisma/client';
import { format, parseISO } from 'date-fns'; import { format, parseISO } from 'date-fns';
import { cloneDeep, groupBy } from 'lodash'; import { cloneDeep, groupBy, isNumber } from 'lodash';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
@ -299,6 +299,12 @@ export class DataService {
].dateOfFirstActivity ].dateOfFirstActivity
? parseISO(response.holdings[symbol].dateOfFirstActivity) ? parseISO(response.holdings[symbol].dateOfFirstActivity)
: undefined; : undefined;
response.holdings[symbol].value = isNumber(
response.holdings[symbol].value
)
? response.holdings[symbol].value
: response.holdings[symbol].valueInPercentage;
} }
} }
@ -333,9 +339,23 @@ export class DataService {
} }
public fetchPortfolioPublic(aId: string) { public fetchPortfolioPublic(aId: string) {
return this.http.get<PortfolioPublicDetails>( return this.http
`/api/v1/portfolio/public/${aId}` .get<PortfolioPublicDetails>(`/api/v1/portfolio/public/${aId}`)
); .pipe(
map((response) => {
if (response.holdings) {
for (const symbol of Object.keys(response.holdings)) {
response.holdings[symbol].value = isNumber(
response.holdings[symbol].value
)
? response.holdings[symbol].value
: response.holdings[symbol].valueInPercentage;
}
}
return response;
})
);
} }
public fetchPortfolioReport() { public fetchPortfolioReport() {

2
libs/common/src/lib/interfaces/historical-data-item.interface.ts

@ -2,9 +2,11 @@ export interface HistoricalDataItem {
averagePrice?: number; averagePrice?: number;
date: string; date: string;
grossPerformancePercent?: number; grossPerformancePercent?: number;
marketPrice?: number;
netPerformance?: number; netPerformance?: number;
netPerformanceInPercentage?: number; netPerformanceInPercentage?: number;
quantity?: number; quantity?: number;
totalInvestment?: number; totalInvestment?: number;
value?: number; value?: number;
valueInPercentage?: number;
} }

3
libs/common/src/lib/interfaces/portfolio-position.interface.ts

@ -30,5 +30,6 @@ export interface PortfolioPosition {
symbol: string; symbol: string;
type?: string; type?: string;
url?: string; url?: string;
value: number; value?: number;
valueInPercentage?: number;
} }

1
libs/common/src/lib/interfaces/portfolio-public-details.interface.ts

@ -18,6 +18,7 @@ export interface PortfolioPublicDetails {
| 'symbol' | 'symbol'
| 'url' | 'url'
| 'value' | 'value'
| 'valueInPercentage'
>; >;
}; };
} }

Loading…
Cancel
Save