From 6c1317f978170fadb747080b6c332c0c6c1826ce Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 13 Jul 2024 20:11:40 +0200 Subject: [PATCH] Bugfix/fix search for holding in assistant (#3569) * Fix search for holding * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/account/account.service.ts | 4 +-- apps/api/src/app/order/order.service.ts | 32 +++++++++++++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4650e927..193fe9d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed an issue in the portfolio summary with the currency conversion of fees +- Fixed an issue in the the search for a holding - Removed the show condition of the experimental features setting in the user settings ## 2.95.0 - 2024-07-12 diff --git a/apps/api/src/app/account/account.service.ts b/apps/api/src/app/account/account.service.ts index 1564fa5b3..37876dde0 100644 --- a/apps/api/src/app/account/account.service.ts +++ b/apps/api/src/app/account/account.service.ts @@ -174,8 +174,8 @@ export class AccountService { ACCOUNT: filtersByAccount, ASSET_CLASS: filtersByAssetClass, TAG: filtersByTag - } = groupBy(filters, (filter) => { - return filter.type; + } = groupBy(filters, ({ type }) => { + return type; }); if (filtersByAccount?.length > 0) { diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index 0255a5011..b743eb2b7 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -312,10 +312,14 @@ export class OrderService { ACCOUNT: filtersByAccount, ASSET_CLASS: filtersByAssetClass, TAG: filtersByTag - } = groupBy(filters, (filter) => { - return filter.type; + } = groupBy(filters, ({ type }) => { + return type; }); + const searchQuery = filters?.find(({ type }) => { + return type === 'SEARCH_QUERY'; + })?.id; + if (filtersByAccount?.length > 0) { where.accountId = { in: filtersByAccount.map(({ id }) => { @@ -357,6 +361,30 @@ export class OrderService { }; } + if (searchQuery) { + const searchQueryWhereInput: Prisma.SymbolProfileWhereInput[] = [ + { id: { mode: 'insensitive', startsWith: searchQuery } }, + { isin: { mode: 'insensitive', startsWith: searchQuery } }, + { name: { mode: 'insensitive', startsWith: searchQuery } }, + { symbol: { mode: 'insensitive', startsWith: searchQuery } } + ]; + + if (where.SymbolProfile) { + where.SymbolProfile = { + AND: [ + where.SymbolProfile, + { + OR: searchQueryWhereInput + } + ] + }; + } else { + where.SymbolProfile = { + OR: searchQueryWhereInput + }; + } + } + if (filtersByTag?.length > 0) { where.tags = { some: {