|
|
@ -556,26 +556,17 @@ export class ActivitiesService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
ACCOUNT: filtersByAccount, |
|
|
ACCOUNT: filtersByAccount = [], |
|
|
ASSET_CLASS: filtersByAssetClass, |
|
|
ASSET_CLASS: filtersByAssetClass = [], |
|
|
TAG: filtersByTag |
|
|
DATA_SOURCE: [filterByDataSource] = [], |
|
|
|
|
|
SEARCH_QUERY: [filterBySearchQuery] = [], |
|
|
|
|
|
SYMBOL: [filterBySymbol] = [], |
|
|
|
|
|
TAG: filtersByTag = [] |
|
|
} = groupBy(filters, ({ type }) => { |
|
|
} = groupBy(filters, ({ type }) => { |
|
|
return type; |
|
|
return type; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const filterByDataSource = filters?.find(({ type }) => { |
|
|
if (filtersByAccount.length > 0) { |
|
|
return type === 'DATA_SOURCE'; |
|
|
|
|
|
})?.id; |
|
|
|
|
|
|
|
|
|
|
|
const filterBySymbol = filters?.find(({ type }) => { |
|
|
|
|
|
return type === 'SYMBOL'; |
|
|
|
|
|
})?.id; |
|
|
|
|
|
|
|
|
|
|
|
const searchQuery = filters?.find(({ type }) => { |
|
|
|
|
|
return type === 'SEARCH_QUERY'; |
|
|
|
|
|
})?.id; |
|
|
|
|
|
|
|
|
|
|
|
if (filtersByAccount?.length > 0) { |
|
|
|
|
|
where.accountId = { |
|
|
where.accountId = { |
|
|
in: filtersByAccount.map(({ id }) => { |
|
|
in: filtersByAccount.map(({ id }) => { |
|
|
return id; |
|
|
return id; |
|
|
@ -587,7 +578,7 @@ export class ActivitiesService { |
|
|
where.isDraft = false; |
|
|
where.isDraft = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (filtersByAssetClass?.length > 0) { |
|
|
if (filtersByAssetClass.length > 0) { |
|
|
where.SymbolProfile = { |
|
|
where.SymbolProfile = { |
|
|
OR: [ |
|
|
OR: [ |
|
|
{ |
|
|
{ |
|
|
@ -623,8 +614,8 @@ export class ActivitiesService { |
|
|
where.SymbolProfile, |
|
|
where.SymbolProfile, |
|
|
{ |
|
|
{ |
|
|
AND: [ |
|
|
AND: [ |
|
|
{ dataSource: filterByDataSource as DataSource }, |
|
|
{ dataSource: filterByDataSource.id as DataSource }, |
|
|
{ symbol: filterBySymbol } |
|
|
{ symbol: filterBySymbol.id } |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
@ -632,19 +623,19 @@ export class ActivitiesService { |
|
|
} else { |
|
|
} else { |
|
|
where.SymbolProfile = { |
|
|
where.SymbolProfile = { |
|
|
AND: [ |
|
|
AND: [ |
|
|
{ dataSource: filterByDataSource as DataSource }, |
|
|
{ dataSource: filterByDataSource.id as DataSource }, |
|
|
{ symbol: filterBySymbol } |
|
|
{ symbol: filterBySymbol.id } |
|
|
] |
|
|
] |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (searchQuery) { |
|
|
if (filterBySearchQuery) { |
|
|
const searchQueryWhereInput: Prisma.SymbolProfileWhereInput[] = [ |
|
|
const searchQueryWhereInput: Prisma.SymbolProfileWhereInput[] = [ |
|
|
{ id: { mode: 'insensitive', startsWith: searchQuery } }, |
|
|
{ id: { mode: 'insensitive', startsWith: filterBySearchQuery.id } }, |
|
|
{ isin: { mode: 'insensitive', startsWith: searchQuery } }, |
|
|
{ isin: { mode: 'insensitive', startsWith: filterBySearchQuery.id } }, |
|
|
{ name: { mode: 'insensitive', startsWith: searchQuery } }, |
|
|
{ name: { mode: 'insensitive', startsWith: filterBySearchQuery.id } }, |
|
|
{ symbol: { mode: 'insensitive', startsWith: searchQuery } } |
|
|
{ symbol: { mode: 'insensitive', startsWith: filterBySearchQuery.id } } |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
if (where.SymbolProfile) { |
|
|
if (where.SymbolProfile) { |
|
|
@ -663,7 +654,7 @@ export class ActivitiesService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (filtersByTag?.length > 0) { |
|
|
if (filtersByTag.length > 0) { |
|
|
where.tags = { |
|
|
where.tags = { |
|
|
some: { |
|
|
some: { |
|
|
OR: filtersByTag.map(({ id }) => { |
|
|
OR: filtersByTag.map(({ id }) => { |
|
|
|