|
|
@ -2,8 +2,9 @@ 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 { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.interceptor'; |
|
|
import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; |
|
|
import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; |
|
|
import { ApiService } from '@ghostfolio/api/services/api/api.service'; |
|
|
import { ApiService } from '@ghostfolio/api/services/api/api.service'; |
|
|
|
|
|
import { getIntervalFromDateRange } from '@ghostfolio/common/calculation-helper'; |
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
import { ExportResponse } from '@ghostfolio/common/interfaces'; |
|
|
import type { RequestWithUser } from '@ghostfolio/common/types'; |
|
|
import type { DateRange, RequestWithUser } from '@ghostfolio/common/types'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
Controller, |
|
|
Controller, |
|
|
@ -37,12 +38,20 @@ export class ExportController { |
|
|
@Query('activityTypes') filterByTypes?: string, |
|
|
@Query('activityTypes') filterByTypes?: string, |
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
@Query('assetClasses') filterByAssetClasses?: string, |
|
|
@Query('dataSource') filterByDataSource?: string, |
|
|
@Query('dataSource') filterByDataSource?: string, |
|
|
|
|
|
@Query('range') dateRange?: DateRange, |
|
|
@Query('symbol') filterBySymbol?: string, |
|
|
@Query('symbol') filterBySymbol?: string, |
|
|
@Query('tags') filterByTags?: string |
|
|
@Query('tags') filterByTags?: string |
|
|
): Promise<ExportResponse> { |
|
|
): Promise<ExportResponse> { |
|
|
const activityIds = filterByActivityIds?.split(',') ?? []; |
|
|
const activityIds = filterByActivityIds?.split(',') ?? []; |
|
|
const activityTypes = (filterByTypes?.split(',') as ActivityType[]) ?? []; |
|
|
const activityTypes = (filterByTypes?.split(',') as ActivityType[]) ?? []; |
|
|
|
|
|
|
|
|
|
|
|
let endDate: Date; |
|
|
|
|
|
let startDate: Date; |
|
|
|
|
|
|
|
|
|
|
|
if (dateRange) { |
|
|
|
|
|
({ endDate, startDate } = getIntervalFromDateRange({ dateRange })); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
filterByAccounts, |
|
|
filterByAccounts, |
|
|
filterByAssetClasses, |
|
|
filterByAssetClasses, |
|
|
@ -54,7 +63,9 @@ export class ExportController { |
|
|
return this.exportService.export({ |
|
|
return this.exportService.export({ |
|
|
activityIds, |
|
|
activityIds, |
|
|
activityTypes, |
|
|
activityTypes, |
|
|
|
|
|
endDate, |
|
|
filters, |
|
|
filters, |
|
|
|
|
|
startDate, |
|
|
userId: this.request.user.id, |
|
|
userId: this.request.user.id, |
|
|
userSettings: this.request.user.settings.settings |
|
|
userSettings: this.request.user.settings.settings |
|
|
}); |
|
|
}); |
|
|
|