Refactoring (#1545)
This commit is contained in:
parent
e8d65e1c85
commit
66d5793528
@ -18,7 +18,6 @@ import {
|
|||||||
PortfolioPublicDetails,
|
PortfolioPublicDetails,
|
||||||
PortfolioReport
|
PortfolioReport
|
||||||
} from '@ghostfolio/common/interfaces';
|
} from '@ghostfolio/common/interfaces';
|
||||||
import { InvestmentItem } from '@ghostfolio/common/interfaces/investment-item.interface';
|
|
||||||
import type {
|
import type {
|
||||||
DateRange,
|
DateRange,
|
||||||
GroupBy,
|
GroupBy,
|
||||||
@ -193,20 +192,11 @@ export class PortfolioController {
|
|||||||
@Query('range') dateRange: DateRange = 'max',
|
@Query('range') dateRange: DateRange = 'max',
|
||||||
@Query('groupBy') groupBy?: GroupBy
|
@Query('groupBy') groupBy?: GroupBy
|
||||||
): Promise<PortfolioDividends> {
|
): Promise<PortfolioDividends> {
|
||||||
let dividends: InvestmentItem[];
|
let dividends = await this.portfolioService.getDividends({
|
||||||
|
dateRange,
|
||||||
if (groupBy === 'month') {
|
groupBy,
|
||||||
dividends = await this.portfolioService.getDividends({
|
impersonationId
|
||||||
dateRange,
|
});
|
||||||
groupBy,
|
|
||||||
impersonationId
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dividends = await this.portfolioService.getDividends({
|
|
||||||
dateRange,
|
|
||||||
impersonationId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
impersonationId ||
|
impersonationId ||
|
||||||
@ -242,20 +232,11 @@ export class PortfolioController {
|
|||||||
@Query('range') dateRange: DateRange = 'max',
|
@Query('range') dateRange: DateRange = 'max',
|
||||||
@Query('groupBy') groupBy?: GroupBy
|
@Query('groupBy') groupBy?: GroupBy
|
||||||
): Promise<PortfolioInvestments> {
|
): Promise<PortfolioInvestments> {
|
||||||
let investments: InvestmentItem[];
|
let investments = await this.portfolioService.getInvestments({
|
||||||
|
dateRange,
|
||||||
if (groupBy === 'month') {
|
groupBy,
|
||||||
investments = await this.portfolioService.getInvestments({
|
impersonationId
|
||||||
dateRange,
|
});
|
||||||
groupBy,
|
|
||||||
impersonationId
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
investments = await this.portfolioService.getInvestments({
|
|
||||||
dateRange,
|
|
||||||
impersonationId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
impersonationId ||
|
impersonationId ||
|
||||||
|
@ -210,12 +210,12 @@ export class PortfolioService {
|
|||||||
|
|
||||||
public async getDividends({
|
public async getDividends({
|
||||||
dateRange,
|
dateRange,
|
||||||
impersonationId,
|
groupBy,
|
||||||
groupBy
|
impersonationId
|
||||||
}: {
|
}: {
|
||||||
dateRange: DateRange;
|
dateRange: DateRange;
|
||||||
impersonationId: string;
|
|
||||||
groupBy?: GroupBy;
|
groupBy?: GroupBy;
|
||||||
|
impersonationId: string;
|
||||||
}): Promise<InvestmentItem[]> {
|
}): Promise<InvestmentItem[]> {
|
||||||
const userId = await this.getUserId(impersonationId, this.request.user.id);
|
const userId = await this.getUserId(impersonationId, this.request.user.id);
|
||||||
|
|
||||||
@ -248,12 +248,12 @@ export class PortfolioService {
|
|||||||
|
|
||||||
public async getInvestments({
|
public async getInvestments({
|
||||||
dateRange,
|
dateRange,
|
||||||
impersonationId,
|
groupBy,
|
||||||
groupBy
|
impersonationId
|
||||||
}: {
|
}: {
|
||||||
dateRange: DateRange;
|
dateRange: DateRange;
|
||||||
impersonationId: string;
|
|
||||||
groupBy?: GroupBy;
|
groupBy?: GroupBy;
|
||||||
|
impersonationId: string;
|
||||||
}): Promise<InvestmentItem[]> {
|
}): Promise<InvestmentItem[]> {
|
||||||
const userId = await this.getUserId(impersonationId, this.request.user.id);
|
const userId = await this.getUserId(impersonationId, this.request.user.id);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user