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