|
|
@ -143,7 +143,7 @@ export class PortfolioService { |
|
|
const where: Prisma.AccountWhereInput = { userId }; |
|
|
const where: Prisma.AccountWhereInput = { userId }; |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
ACCOUNT: [filterByAccount] = [], |
|
|
ACCOUNT: filtersByAccount = [], |
|
|
ASSET_CLASS: filtersByAssetClass = [], |
|
|
ASSET_CLASS: filtersByAssetClass = [], |
|
|
DATA_SOURCE: [filterByDataSource] = [], |
|
|
DATA_SOURCE: [filterByDataSource] = [], |
|
|
SYMBOL: [filterBySymbol] = [], |
|
|
SYMBOL: [filterBySymbol] = [], |
|
|
@ -152,24 +152,28 @@ export class PortfolioService { |
|
|
return type; |
|
|
return type; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (filterByAccount) { |
|
|
if (filtersByAccount.length > 0) { |
|
|
where.id = filterByAccount.id; |
|
|
where.id = { |
|
|
|
|
|
in: filtersByAccount.map(({ id }) => { |
|
|
|
|
|
return id; |
|
|
|
|
|
}) |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const whereAccountConditions: Prisma.AccountWhereInput[] = []; |
|
|
const whereAccountConditions: Prisma.AccountWhereInput[] = []; |
|
|
const whereActivityConditions: Prisma.OrderWhereInput[] = []; |
|
|
const whereActivityConditions: Prisma.OrderWhereInput[] = []; |
|
|
|
|
|
|
|
|
if (filtersByAssetClass.length > 0) { |
|
|
if (filtersByAssetClass.length > 0) { |
|
|
|
|
|
const whereAssetClassConditions = filtersByAssetClass.map(({ id }) => { |
|
|
|
|
|
return { assetClass: AssetClass[id] }; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const whereActivityOfAssetClass: Prisma.OrderWhereInput = { |
|
|
const whereActivityOfAssetClass: Prisma.OrderWhereInput = { |
|
|
SymbolProfile: { |
|
|
SymbolProfile: { |
|
|
OR: [ |
|
|
OR: [ |
|
|
{ |
|
|
{ |
|
|
AND: [ |
|
|
AND: [ |
|
|
{ |
|
|
{ OR: whereAssetClassConditions }, |
|
|
OR: filtersByAssetClass.map(({ id }) => { |
|
|
|
|
|
return { assetClass: AssetClass[id] }; |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
{ |
|
|
OR: [ |
|
|
OR: [ |
|
|
{ assetProfileOverrides: { is: null } }, |
|
|
{ assetProfileOverrides: { is: null } }, |
|
|
@ -179,11 +183,7 @@ export class PortfolioService { |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
assetProfileOverrides: { |
|
|
assetProfileOverrides: { OR: whereAssetClassConditions } |
|
|
OR: filtersByAssetClass.map(({ id }) => { |
|
|
|
|
|
return { assetClass: AssetClass[id] }; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
@ -222,25 +222,25 @@ export class PortfolioService { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const whereTagsOfActivity: Prisma.TagListRelationFilter = { |
|
|
|
|
|
some: { |
|
|
|
|
|
OR: filtersByTag.map(({ id }) => { |
|
|
|
|
|
return { id }; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const whereActivityOfTag: Prisma.OrderWhereInput = { |
|
|
const whereActivityOfTag: Prisma.OrderWhereInput = { |
|
|
OR: [ |
|
|
OR: [ |
|
|
{ |
|
|
{ account: { tags: whereTagsOfAccount } }, |
|
|
tags: { |
|
|
{ tags: whereTagsOfActivity } |
|
|
some: { |
|
|
|
|
|
OR: filtersByTag.map(({ id }) => { |
|
|
|
|
|
return { id }; |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
{ account: { tags: whereTagsOfAccount } } |
|
|
|
|
|
] |
|
|
] |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
whereAccountConditions.push({ |
|
|
whereAccountConditions.push({ |
|
|
OR: [ |
|
|
OR: [ |
|
|
{ tags: whereTagsOfAccount }, |
|
|
{ activities: { some: { tags: whereTagsOfActivity } } }, |
|
|
{ activities: { some: whereActivityOfTag } } |
|
|
{ tags: whereTagsOfAccount } |
|
|
] |
|
|
] |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|