Browse Source
Task/refactor Export interface to ExportResponse interface (#5805)
* Refactor Export interface to ExportResponse interface
pull/5554/merge
Ani07-05
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with
25 additions and
25 deletions
-
apps/api/src/app/export/export.controller.ts
-
apps/api/src/app/export/export.service.ts
-
apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
-
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btceur.spec.ts
-
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-short.spec.ts
-
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd.spec.ts
-
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts
-
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts
-
apps/client/src/app/services/data.service.ts
-
apps/client/src/app/services/ics/ics.service.ts
-
libs/common/src/lib/interfaces/index.ts
-
libs/common/src/lib/interfaces/responses/export-response.interface.ts
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard'; |
|
|
|
import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.interceptor'; |
|
|
|
import { ApiService } from '@ghostfolio/api/services/api/api.service'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import type { RequestWithUser } from '@ghostfolio/common/types'; |
|
|
|
|
|
|
|
import { |
|
|
|
@ -35,7 +35,7 @@ export class ExportController { |
|
|
|
@Query('dataSource') filterByDataSource?: string, |
|
|
|
@Query('symbol') filterBySymbol?: string, |
|
|
|
@Query('tags') filterByTags?: string |
|
|
|
): Promise<Export> { |
|
|
|
): Promise<ExportResponse> { |
|
|
|
const activityIds = filterByActivityIds?.split(',') ?? []; |
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
|
filterByAccounts, |
|
|
|
|
|
|
|
@ -3,7 +3,7 @@ import { OrderService } from '@ghostfolio/api/app/order/order.service'; |
|
|
|
import { environment } from '@ghostfolio/api/environments/environment'; |
|
|
|
import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; |
|
|
|
import { TagService } from '@ghostfolio/api/services/tag/tag.service'; |
|
|
|
import { Filter, Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse, Filter } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common'; |
|
|
|
import { Platform, Prisma } from '@prisma/client'; |
|
|
|
@ -28,7 +28,7 @@ export class ExportService { |
|
|
|
filters?: Filter[]; |
|
|
|
userCurrency: string; |
|
|
|
userId: string; |
|
|
|
}): Promise<Export> { |
|
|
|
}): Promise<ExportResponse> { |
|
|
|
const { ACCOUNT: filtersByAccount } = groupBy(filters, ({ type }) => { |
|
|
|
return type; |
|
|
|
}); |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
import { readFileSync } from 'node:fs'; |
|
|
|
|
|
|
|
@ -39,6 +39,6 @@ export const userDummyData = { |
|
|
|
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' |
|
|
|
}; |
|
|
|
|
|
|
|
export function loadExportFile(filePath: string): Export { |
|
|
|
export function loadExportFile(filePath: string): ExportResponse { |
|
|
|
return JSON.parse(readFileSync(filePath, 'utf8')); |
|
|
|
} |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate- |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { PortfolioSnapshotServiceMock } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock'; |
|
|
|
import { parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; |
|
|
|
|
|
|
|
import { Big } from 'big.js'; |
|
|
|
@ -52,7 +52,7 @@ jest.mock('@ghostfolio/api/app/redis-cache/redis-cache.service', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('PortfolioCalculator', () => { |
|
|
|
let exportResponse: Export; |
|
|
|
let exportResponse: ExportResponse; |
|
|
|
|
|
|
|
let configurationService: ConfigurationService; |
|
|
|
let currentRateService: CurrentRateService; |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate- |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { PortfolioSnapshotServiceMock } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock'; |
|
|
|
import { parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; |
|
|
|
|
|
|
|
import { Big } from 'big.js'; |
|
|
|
@ -52,7 +52,7 @@ jest.mock('@ghostfolio/api/app/redis-cache/redis-cache.service', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('PortfolioCalculator', () => { |
|
|
|
let exportResponse: Export; |
|
|
|
let exportResponse: ExportResponse; |
|
|
|
|
|
|
|
let configurationService: ConfigurationService; |
|
|
|
let currentRateService: CurrentRateService; |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate- |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { PortfolioSnapshotServiceMock } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock'; |
|
|
|
import { parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; |
|
|
|
|
|
|
|
import { Big } from 'big.js'; |
|
|
|
@ -52,7 +52,7 @@ jest.mock('@ghostfolio/api/app/redis-cache/redis-cache.service', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('PortfolioCalculator', () => { |
|
|
|
let exportResponse: Export; |
|
|
|
let exportResponse: ExportResponse; |
|
|
|
|
|
|
|
let configurationService: ConfigurationService; |
|
|
|
let currentRateService: CurrentRateService; |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate- |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { PortfolioSnapshotServiceMock } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock'; |
|
|
|
import { parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; |
|
|
|
|
|
|
|
import { Big } from 'big.js'; |
|
|
|
@ -52,7 +52,7 @@ jest.mock('@ghostfolio/api/app/redis-cache/redis-cache.service', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('PortfolioCalculator', () => { |
|
|
|
let exportResponse: Export; |
|
|
|
let exportResponse: ExportResponse; |
|
|
|
|
|
|
|
let configurationService: ConfigurationService; |
|
|
|
let currentRateService: CurrentRateService; |
|
|
|
|
|
|
|
@ -15,7 +15,7 @@ import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate- |
|
|
|
import { PortfolioSnapshotService } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service'; |
|
|
|
import { PortfolioSnapshotServiceMock } from '@ghostfolio/api/services/queues/portfolio-snapshot/portfolio-snapshot.service.mock'; |
|
|
|
import { parseDate } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; |
|
|
|
|
|
|
|
import { Big } from 'big.js'; |
|
|
|
@ -52,7 +52,7 @@ jest.mock('@ghostfolio/api/app/redis-cache/redis-cache.service', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('PortfolioCalculator', () => { |
|
|
|
let exportResponse: Export; |
|
|
|
let exportResponse: ExportResponse; |
|
|
|
|
|
|
|
let configurationService: ConfigurationService; |
|
|
|
let currentRateService: CurrentRateService; |
|
|
|
|
|
|
|
@ -34,7 +34,7 @@ import { |
|
|
|
BenchmarkMarketDataDetailsResponse, |
|
|
|
BenchmarkResponse, |
|
|
|
DataProviderHealthResponse, |
|
|
|
Export, |
|
|
|
ExportResponse, |
|
|
|
Filter, |
|
|
|
ImportResponse, |
|
|
|
InfoItem, |
|
|
|
@ -407,7 +407,7 @@ export class DataService { |
|
|
|
params = params.append('activityIds', activityIds.join(',')); |
|
|
|
} |
|
|
|
|
|
|
|
return this.http.get<Export>('/api/v1/export', { |
|
|
|
return this.http.get<ExportResponse>('/api/v1/export', { |
|
|
|
params |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import { capitalize } from '@ghostfolio/common/helper'; |
|
|
|
import { Export } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { Type } from '@prisma/client'; |
|
|
|
@ -13,7 +13,7 @@ export class IcsService { |
|
|
|
private readonly ICS_LINE_BREAK = '\r\n'; |
|
|
|
|
|
|
|
public transformActivitiesToIcsContent( |
|
|
|
aActivities: Export['activities'] |
|
|
|
aActivities: ExportResponse['activities'] |
|
|
|
): string { |
|
|
|
const header = [ |
|
|
|
'BEGIN:VCALENDAR', |
|
|
|
|
|
|
|
@ -15,7 +15,6 @@ import type { Benchmark } from './benchmark.interface'; |
|
|
|
import type { Coupon } from './coupon.interface'; |
|
|
|
import type { DataProviderInfo } from './data-provider-info.interface'; |
|
|
|
import type { EnhancedSymbolProfile } from './enhanced-symbol-profile.interface'; |
|
|
|
import type { Export } from './export.interface'; |
|
|
|
import type { FilterGroup } from './filter-group.interface'; |
|
|
|
import type { Filter } from './filter.interface'; |
|
|
|
import type { FireWealth } from './fire-wealth.interface'; |
|
|
|
@ -49,6 +48,7 @@ import type { DataProviderGhostfolioStatusResponse } from './responses/data-prov |
|
|
|
import type { DataProviderHealthResponse } from './responses/data-provider-health-response.interface'; |
|
|
|
import type { DividendsResponse } from './responses/dividends-response.interface'; |
|
|
|
import type { ResponseError } from './responses/errors.interface'; |
|
|
|
import type { ExportResponse } from './responses/export-response.interface'; |
|
|
|
import type { HistoricalResponse } from './responses/historical-response.interface'; |
|
|
|
import type { ImportResponse } from './responses/import-response.interface'; |
|
|
|
import type { InfoResponse } from './responses/info-response.interface'; |
|
|
|
@ -105,7 +105,7 @@ export { |
|
|
|
DataProviderInfo, |
|
|
|
DividendsResponse, |
|
|
|
EnhancedSymbolProfile, |
|
|
|
Export, |
|
|
|
ExportResponse, |
|
|
|
Filter, |
|
|
|
FilterGroup, |
|
|
|
FireWealth, |
|
|
|
|
|
|
|
@ -7,10 +7,10 @@ import { |
|
|
|
Tag |
|
|
|
} from '@prisma/client'; |
|
|
|
|
|
|
|
import { AccountBalance } from './account-balance.interface'; |
|
|
|
import { MarketData } from './market-data.interface'; |
|
|
|
import { AccountBalance } from '../account-balance.interface'; |
|
|
|
import { MarketData } from '../market-data.interface'; |
|
|
|
|
|
|
|
export interface Export { |
|
|
|
export interface ExportResponse { |
|
|
|
accounts: (Omit<Account, 'createdAt' | 'updatedAt' | 'userId'> & { |
|
|
|
balances: AccountBalance[]; |
|
|
|
})[]; |