Feature/clean up deprecated GET api/portfolio/positions endpoint (#3373)
This commit is contained in:
parent
1fd836194f
commit
4ad4fa2b30
@ -1,5 +0,0 @@
|
||||
import { Position } from '@ghostfolio/common/interfaces';
|
||||
|
||||
export interface PortfolioPositions {
|
||||
positions: Position[];
|
||||
}
|
@ -52,7 +52,6 @@ import { Big } from 'big.js';
|
||||
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
|
||||
|
||||
import { PortfolioPositionDetail } from './interfaces/portfolio-position-detail.interface';
|
||||
import { PortfolioPositions } from './interfaces/portfolio-positions.interface';
|
||||
import { PortfolioService } from './portfolio.service';
|
||||
|
||||
@Controller('portfolio')
|
||||
@ -494,35 +493,6 @@ export class PortfolioController {
|
||||
return performanceInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Get('positions')
|
||||
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
|
||||
@UseInterceptors(RedactValuesInResponseInterceptor)
|
||||
@UseInterceptors(TransformDataSourceInResponseInterceptor)
|
||||
public async getPositions(
|
||||
@Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId: string,
|
||||
@Query('accounts') filterByAccounts?: string,
|
||||
@Query('assetClasses') filterByAssetClasses?: string,
|
||||
@Query('query') filterBySearchQuery?: string,
|
||||
@Query('range') dateRange: DateRange = 'max',
|
||||
@Query('tags') filterByTags?: string
|
||||
): Promise<PortfolioPositions> {
|
||||
const filters = this.apiService.buildFiltersFromQueryParams({
|
||||
filterByAccounts,
|
||||
filterByAssetClasses,
|
||||
filterBySearchQuery,
|
||||
filterByTags
|
||||
});
|
||||
|
||||
return this.portfolioService.getPositions({
|
||||
dateRange,
|
||||
filters,
|
||||
impersonationId
|
||||
});
|
||||
}
|
||||
|
||||
@Get('public/:accessId')
|
||||
@UseInterceptors(TransformDataSourceInResponseInterceptor)
|
||||
public async getPublic(
|
||||
|
@ -2,7 +2,7 @@ import { CreateAccountDto } from '@ghostfolio/api/app/account/create-account.dto
|
||||
import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface';
|
||||
import { DataService } from '@ghostfolio/client/services/data.service';
|
||||
import { ImportActivitiesService } from '@ghostfolio/client/services/import-activities.service';
|
||||
import { Position } from '@ghostfolio/common/interfaces';
|
||||
import { PortfolioPosition } from '@ghostfolio/common/interfaces';
|
||||
|
||||
import {
|
||||
StepperOrientation,
|
||||
@ -43,7 +43,7 @@ export class ImportActivitiesDialog implements OnDestroy {
|
||||
public deviceType: string;
|
||||
public dialogTitle = $localize`Import Activities`;
|
||||
public errorMessages: string[] = [];
|
||||
public holdings: Position[] = [];
|
||||
public holdings: PortfolioPosition[] = [];
|
||||
public importStep: ImportStep = ImportStep.UPLOAD_FILE;
|
||||
public isLoading = false;
|
||||
public maxSafeInteger = Number.MAX_SAFE_INTEGER;
|
||||
@ -88,7 +88,7 @@ export class ImportActivitiesDialog implements OnDestroy {
|
||||
this.uniqueAssetForm.get('uniqueAsset').disable();
|
||||
|
||||
this.dataService
|
||||
.fetchPositions({
|
||||
.fetchPortfolioHoldings({
|
||||
filters: [
|
||||
{
|
||||
id: AssetClass.EQUITY,
|
||||
@ -98,8 +98,8 @@ export class ImportActivitiesDialog implements OnDestroy {
|
||||
range: 'max'
|
||||
})
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(({ positions }) => {
|
||||
this.holdings = sortBy(positions, ({ name }) => {
|
||||
.subscribe(({ holdings }) => {
|
||||
this.holdings = sortBy(holdings, ({ name }) => {
|
||||
return name.toLowerCase();
|
||||
});
|
||||
this.uniqueAssetForm.get('uniqueAsset').enable();
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
HistoricalDataItem,
|
||||
PortfolioInvestments,
|
||||
PortfolioPerformance,
|
||||
Position,
|
||||
PortfolioPosition,
|
||||
User
|
||||
} from '@ghostfolio/common/interfaces';
|
||||
import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface';
|
||||
@ -35,7 +35,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
|
||||
public benchmark: Partial<SymbolProfile>;
|
||||
public benchmarkDataItems: HistoricalDataItem[] = [];
|
||||
public benchmarks: Partial<SymbolProfile>[];
|
||||
public bottom3: Position[];
|
||||
public bottom3: PortfolioPosition[];
|
||||
public dateRangeOptions = ToggleComponent.DEFAULT_DATE_RANGE_OPTIONS;
|
||||
public daysInMarket: number;
|
||||
public deviceType: string;
|
||||
@ -60,7 +60,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
|
||||
public performanceDataItemsInPercentage: HistoricalDataItem[];
|
||||
public portfolioEvolutionDataLabel = $localize`Investment`;
|
||||
public streaks: PortfolioInvestments['streaks'];
|
||||
public top3: Position[];
|
||||
public top3: PortfolioPosition[];
|
||||
public unitCurrentStreak: string;
|
||||
public unitLongestStreak: string;
|
||||
public user: User;
|
||||
@ -308,23 +308,23 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
|
||||
});
|
||||
|
||||
this.dataService
|
||||
.fetchPositions({
|
||||
.fetchPortfolioHoldings({
|
||||
filters: this.userService.getFilters(),
|
||||
range: this.user?.settings?.dateRange
|
||||
})
|
||||
.pipe(takeUntil(this.unsubscribeSubject))
|
||||
.subscribe(({ positions }) => {
|
||||
const positionsSorted = sortBy(
|
||||
positions.filter(({ netPerformancePercentageWithCurrencyEffect }) => {
|
||||
return isNumber(netPerformancePercentageWithCurrencyEffect);
|
||||
.subscribe(({ holdings }) => {
|
||||
const holdingsSorted = sortBy(
|
||||
holdings.filter(({ netPerformancePercentWithCurrencyEffect }) => {
|
||||
return isNumber(netPerformancePercentWithCurrencyEffect);
|
||||
}),
|
||||
'netPerformancePercentageWithCurrencyEffect'
|
||||
'netPerformancePercentWithCurrencyEffect'
|
||||
).reverse();
|
||||
|
||||
this.top3 = positionsSorted.slice(0, 3);
|
||||
this.top3 = holdingsSorted.slice(0, 3);
|
||||
|
||||
if (positions?.length > 3) {
|
||||
this.bottom3 = positionsSorted.slice(-3).reverse();
|
||||
if (holdings?.length > 3) {
|
||||
this.bottom3 = holdingsSorted.slice(-3).reverse();
|
||||
} else {
|
||||
this.bottom3 = [];
|
||||
}
|
||||
|
@ -170,17 +170,17 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<ol class="mb-0 ml-1 pl-3">
|
||||
<li *ngFor="let position of top3" class="py-1">
|
||||
<li *ngFor="let holding of top3" class="py-1">
|
||||
<a
|
||||
class="d-flex"
|
||||
[queryParams]="{
|
||||
dataSource: position.dataSource,
|
||||
dataSource: holding.dataSource,
|
||||
positionDetailDialog: true,
|
||||
symbol: position.symbol
|
||||
symbol: holding.symbol
|
||||
}"
|
||||
[routerLink]="[]"
|
||||
>
|
||||
<div class="flex-grow-1 mr-2">{{ position.name }}</div>
|
||||
<div class="flex-grow-1 mr-2">{{ holding.name }}</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<gf-value
|
||||
class="justify-content-end"
|
||||
@ -188,9 +188,7 @@
|
||||
[colorizeSign]="true"
|
||||
[isPercent]="true"
|
||||
[locale]="user?.settings?.locale"
|
||||
[value]="
|
||||
position.netPerformancePercentageWithCurrencyEffect
|
||||
"
|
||||
[value]="holding.netPerformancePercentWithCurrencyEffect"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
@ -218,17 +216,17 @@
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<ol class="mb-0 ml-1 pl-3">
|
||||
<li *ngFor="let position of bottom3" class="py-1">
|
||||
<li *ngFor="let holding of bottom3" class="py-1">
|
||||
<a
|
||||
class="d-flex"
|
||||
[queryParams]="{
|
||||
dataSource: position.dataSource,
|
||||
dataSource: holding.dataSource,
|
||||
positionDetailDialog: true,
|
||||
symbol: position.symbol
|
||||
symbol: holding.symbol
|
||||
}"
|
||||
[routerLink]="[]"
|
||||
>
|
||||
<div class="flex-grow-1 mr-2">{{ position.name }}</div>
|
||||
<div class="flex-grow-1 mr-2">{{ holding.name }}</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<gf-value
|
||||
class="justify-content-end"
|
||||
@ -236,9 +234,7 @@
|
||||
[colorizeSign]="true"
|
||||
[isPercent]="true"
|
||||
[locale]="user?.settings?.locale"
|
||||
[value]="
|
||||
position.netPerformancePercentageWithCurrencyEffect
|
||||
"
|
||||
[value]="holding.netPerformancePercentWithCurrencyEffect"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -6,7 +6,6 @@ import { CreateOrderDto } from '@ghostfolio/api/app/order/create-order.dto';
|
||||
import { Activities } from '@ghostfolio/api/app/order/interfaces/activities.interface';
|
||||
import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto';
|
||||
import { PortfolioPositionDetail } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-position-detail.interface';
|
||||
import { PortfolioPositions } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-positions.interface';
|
||||
import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface';
|
||||
import { SymbolItem } from '@ghostfolio/api/app/symbol/interfaces/symbol-item.interface';
|
||||
import { UserItem } from '@ghostfolio/api/app/user/interfaces/user-item.interface';
|
||||
@ -376,24 +375,6 @@ export class DataService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public fetchPositions({
|
||||
filters,
|
||||
range
|
||||
}: {
|
||||
filters?: Filter[];
|
||||
range: DateRange;
|
||||
}): Observable<PortfolioPositions> {
|
||||
let params = this.buildFiltersAsQueryParams({ filters });
|
||||
params = params.append('range', range);
|
||||
|
||||
return this.http.get<PortfolioPositions>('/api/v1/portfolio/positions', {
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
public fetchSymbols({
|
||||
includeIndices = false,
|
||||
query
|
||||
|
@ -416,7 +416,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
|
||||
|
||||
private searchHoldings(aSearchTerm: string): Observable<ISearchResultItem[]> {
|
||||
return this.dataService
|
||||
.fetchPositions({
|
||||
.fetchPortfolioHoldings({
|
||||
filters: [
|
||||
{
|
||||
id: aSearchTerm,
|
||||
@ -429,8 +429,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
|
||||
catchError(() => {
|
||||
return EMPTY;
|
||||
}),
|
||||
map(({ positions }) => {
|
||||
return positions.map(
|
||||
map(({ holdings }) => {
|
||||
return holdings.map(
|
||||
({ assetSubClass, currency, dataSource, name, symbol }) => {
|
||||
return {
|
||||
currency,
|
||||
|
Loading…
x
Reference in New Issue
Block a user