Browse Source
Feature/refactor search query of holdings search (#5333)
* Refactor search query
* Update changelog
pull/5338/head
Thomas Kaul
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
9 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/portfolio/portfolio.controller.ts
-
apps/api/src/app/portfolio/portfolio.service.ts
|
@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
### Changed |
|
|
### Changed |
|
|
|
|
|
|
|
|
- Extended the import functionality by tags |
|
|
- Extended the import functionality by tags |
|
|
- Introduced fuzzy search for the accounts endpoint |
|
|
- Introduced the fuzzy search for the accounts endpoint |
|
|
|
|
|
- Refactored the fuzzy search for the holdings of the assistant |
|
|
- Improved the language localization for Polish (`pl`) |
|
|
- Improved the language localization for Polish (`pl`) |
|
|
- Improved the language localization for Spanish (`es`) |
|
|
- Improved the language localization for Spanish (`es`) |
|
|
|
|
|
|
|
|
|
@ -413,6 +413,7 @@ export class PortfolioController { |
|
|
filterByAssetClasses, |
|
|
filterByAssetClasses, |
|
|
filterByDataSource, |
|
|
filterByDataSource, |
|
|
filterByHoldingType, |
|
|
filterByHoldingType, |
|
|
|
|
|
filterBySearchQuery, |
|
|
filterBySymbol, |
|
|
filterBySymbol, |
|
|
filterByTags |
|
|
filterByTags |
|
|
}); |
|
|
}); |
|
@ -421,7 +422,6 @@ export class PortfolioController { |
|
|
dateRange, |
|
|
dateRange, |
|
|
filters, |
|
|
filters, |
|
|
impersonationId, |
|
|
impersonationId, |
|
|
query: filterBySearchQuery, |
|
|
|
|
|
userId: this.request.user.id |
|
|
userId: this.request.user.id |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
@ -292,13 +292,11 @@ export class PortfolioService { |
|
|
dateRange, |
|
|
dateRange, |
|
|
filters, |
|
|
filters, |
|
|
impersonationId, |
|
|
impersonationId, |
|
|
query, |
|
|
|
|
|
userId |
|
|
userId |
|
|
}: { |
|
|
}: { |
|
|
dateRange: DateRange; |
|
|
dateRange: DateRange; |
|
|
filters?: Filter[]; |
|
|
filters?: Filter[]; |
|
|
impersonationId: string; |
|
|
impersonationId: string; |
|
|
query?: string; |
|
|
|
|
|
userId: string; |
|
|
userId: string; |
|
|
}) { |
|
|
}) { |
|
|
userId = await this.getUserId(impersonationId, userId); |
|
|
userId = await this.getUserId(impersonationId, userId); |
|
@ -311,13 +309,17 @@ export class PortfolioService { |
|
|
|
|
|
|
|
|
let holdings = Object.values(holdingsMap); |
|
|
let holdings = Object.values(holdingsMap); |
|
|
|
|
|
|
|
|
if (query) { |
|
|
const searchQuery = filters.find(({ type }) => { |
|
|
|
|
|
return type === 'SEARCH_QUERY'; |
|
|
|
|
|
})?.id; |
|
|
|
|
|
|
|
|
|
|
|
if (searchQuery) { |
|
|
const fuse = new Fuse(holdings, { |
|
|
const fuse = new Fuse(holdings, { |
|
|
keys: ['isin', 'name', 'symbol'], |
|
|
keys: ['isin', 'name', 'symbol'], |
|
|
threshold: 0.3 |
|
|
threshold: 0.3 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
holdings = fuse.search(query).map(({ item }) => { |
|
|
holdings = fuse.search(searchQuery).map(({ item }) => { |
|
|
return item; |
|
|
return item; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|