|
|
@ -393,17 +393,7 @@ export class ActivitiesService { |
|
|
userCurrency: string; |
|
|
userCurrency: string; |
|
|
userId: string; |
|
|
userId: string; |
|
|
}): Promise<ActivitiesResponse> { |
|
|
}): Promise<ActivitiesResponse> { |
|
|
const filtersByAssetClass = filters.filter(({ type }) => { |
|
|
if (this.hasNonMatchingFiltersForCashActivities(filters)) { |
|
|
return type === 'ASSET_CLASS'; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
filtersByAssetClass.length > 0 && |
|
|
|
|
|
!filtersByAssetClass.find(({ id }) => { |
|
|
|
|
|
return id === AssetClass.LIQUIDITY; |
|
|
|
|
|
}) |
|
|
|
|
|
) { |
|
|
|
|
|
// If asset class filters are present and none of them is liquidity, return an empty response
|
|
|
|
|
|
return { |
|
|
return { |
|
|
activities: [], |
|
|
activities: [], |
|
|
count: 0 |
|
|
count: 0 |
|
|
@ -810,7 +800,7 @@ export class ActivitiesService { |
|
|
withExcludedAccountsAndActivities: false // TODO
|
|
|
withExcludedAccountsAndActivities: false // TODO
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (withCash) { |
|
|
if (withCash && !this.hasNonMatchingFiltersForCashActivities(filters)) { |
|
|
const cashDetails = await this.accountService.getCashDetails({ |
|
|
const cashDetails = await this.accountService.getCashDetails({ |
|
|
filters, |
|
|
filters, |
|
|
userId, |
|
|
userId, |
|
|
@ -945,6 +935,43 @@ export class ActivitiesService { |
|
|
return activity; |
|
|
return activity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private hasNonMatchingFiltersForCashActivities(filters: Filter[] = []) { |
|
|
|
|
|
const { |
|
|
|
|
|
ASSET_CLASS: filtersByAssetClass = [], |
|
|
|
|
|
DATA_SOURCE: [filterByDataSource] = [], |
|
|
|
|
|
SYMBOL: [filterBySymbol] = [], |
|
|
|
|
|
TAG: filtersByTag = [] |
|
|
|
|
|
} = groupBy(filters, ({ type }) => { |
|
|
|
|
|
return type; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const isFilteredByAssetClassOtherThanLiquidity = |
|
|
|
|
|
filtersByAssetClass.length > 0 && |
|
|
|
|
|
!filtersByAssetClass.some(({ id }) => { |
|
|
|
|
|
return id === AssetClass.LIQUIDITY; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const isFilteredByAssetProfile = !!(filterByDataSource || filterBySymbol); |
|
|
|
|
|
const isFilteredByTag = filtersByTag.length > 0; |
|
|
|
|
|
|
|
|
|
|
|
const isFilteredByUnsupportedType = filters.some(({ type }) => { |
|
|
|
|
|
return ![ |
|
|
|
|
|
'ACCOUNT', |
|
|
|
|
|
'ASSET_CLASS', |
|
|
|
|
|
'DATA_SOURCE', |
|
|
|
|
|
'SYMBOL', |
|
|
|
|
|
'TAG' |
|
|
|
|
|
].includes(type); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
isFilteredByAssetClassOtherThanLiquidity || |
|
|
|
|
|
isFilteredByAssetProfile || |
|
|
|
|
|
isFilteredByTag || |
|
|
|
|
|
isFilteredByUnsupportedType |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async orders(params: { |
|
|
private async orders(params: { |
|
|
include?: Prisma.OrderInclude; |
|
|
include?: Prisma.OrderInclude; |
|
|
skip?: number; |
|
|
skip?: number; |
|
|
|