Feature/filter public endpoint by equity asset class (#1014)

* Filter by ASSET_CLASS: EQUITY

* Update changelog
This commit is contained in:
Thomas Kaul 2022-06-15 13:21:47 +02:00 committed by GitHub
parent 8d2e110e3d
commit 3332ade3d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 15 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Changed the default `HOST` to `0.0.0.0`
- Refactored the endpoint of the public page (filter by equity)
## 1.158.1 - 12.06.2022

View File

@ -316,7 +316,9 @@ export class PortfolioController {
const { holdings } = await this.portfolioService.getDetails(
access.userId,
access.userId
access.userId,
'1d',
[{ id: 'EQUITY', type: 'ASSET_CLASS' }]
);
const portfolioPublicDetails: PortfolioPublicDetails = {
@ -325,9 +327,6 @@ export class PortfolioController {
};
const totalValue = Object.values(holdings)
.filter((holding) => {
return holding.assetClass === 'EQUITY';
})
.map((portfolioPosition) => {
return this.exchangeRateDataService.toCurrency(
portfolioPosition.quantity * portfolioPosition.marketPrice,
@ -338,7 +337,6 @@ export class PortfolioController {
.reduce((a, b) => a + b, 0);
for (const [symbol, portfolioPosition] of Object.entries(holdings)) {
if (portfolioPosition.assetClass === 'EQUITY') {
portfolioPublicDetails.holdings[symbol] = {
allocationCurrent: portfolioPosition.allocationCurrent,
countries: hasDetails ? portfolioPosition.countries : [],
@ -349,7 +347,6 @@ export class PortfolioController {
value: portfolioPosition.value / totalValue
};
}
}
return portfolioPublicDetails;
}