Feature/improve search for asset profiles with manual data source in create or update activity dialog (#4142)
* Improve search for asset profiles with MANUAL data source * Update changelog
This commit is contained in:
parent
9a579dd884
commit
f2638614d4
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved the search for asset profiles with `MANUAL` data source in the create or update activity dialog
|
||||
- Improved the usability of the link to manage access with a new icon
|
||||
- Improved support to import activities by `isin` in the _Yahoo Finance_ service
|
||||
- Improved the language localization for Polish (`pl`)
|
||||
|
@ -618,7 +618,8 @@ export class DataProviderService {
|
||||
promises.push(
|
||||
dataProviderService.search({
|
||||
includeIndices,
|
||||
query
|
||||
query,
|
||||
userId: user.id
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -79,4 +79,5 @@ export interface GetQuotesParams {
|
||||
export interface GetSearchParams {
|
||||
includeIndices?: boolean;
|
||||
query: string;
|
||||
userId?: string;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import {
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { DataSource, SymbolProfile } from '@prisma/client';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { isUUID } from 'class-validator';
|
||||
import { addDays, format, isBefore } from 'date-fns';
|
||||
import got, { Headers } from 'got';
|
||||
import * as jsonpath from 'jsonpath';
|
||||
@ -219,39 +218,46 @@ export class ManualService implements DataProviderInterface {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async search({ query }: GetSearchParams): Promise<LookupResponse> {
|
||||
let items = await this.prismaService.symbolProfile.findMany({
|
||||
public async search({
|
||||
query,
|
||||
userId
|
||||
}: GetSearchParams): Promise<LookupResponse> {
|
||||
const items = await this.prismaService.symbolProfile.findMany({
|
||||
select: {
|
||||
assetClass: true,
|
||||
assetSubClass: true,
|
||||
currency: true,
|
||||
dataSource: true,
|
||||
name: true,
|
||||
symbol: true
|
||||
symbol: true,
|
||||
userId: true
|
||||
},
|
||||
where: {
|
||||
AND: [
|
||||
{
|
||||
dataSource: this.getName()
|
||||
},
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
dataSource: this.getName(),
|
||||
name: {
|
||||
mode: 'insensitive',
|
||||
startsWith: query
|
||||
}
|
||||
},
|
||||
{
|
||||
dataSource: this.getName(),
|
||||
symbol: {
|
||||
mode: 'insensitive',
|
||||
startsWith: query
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
OR: [{ userId }, { userId: null }]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
items = items.filter(({ symbol }) => {
|
||||
// Remove UUID symbols (activities of type ITEM)
|
||||
return !isUUID(symbol);
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -20,7 +20,6 @@ import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AssetClass, AssetSubClass, Tag, Type } from '@prisma/client';
|
||||
import { isUUID } from 'class-validator';
|
||||
import { isAfter, isToday } from 'date-fns';
|
||||
import { EMPTY, Observable, Subject, lastValueFrom, of } from 'rxjs';
|
||||
import { catchError, delay, map, startWith, takeUntil } from 'rxjs/operators';
|
||||
@ -476,10 +475,8 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
||||
fee: this.activityForm.get('fee').value,
|
||||
quantity: this.activityForm.get('quantity').value,
|
||||
symbol:
|
||||
this.activityForm.get('searchSymbol').value?.symbol === undefined ||
|
||||
isUUID(this.activityForm.get('searchSymbol').value?.symbol)
|
||||
? this.activityForm.get('name').value
|
||||
: this.activityForm.get('searchSymbol').value.symbol,
|
||||
this.activityForm.get('searchSymbol')?.value?.symbol ??
|
||||
this.activityForm.get('name')?.value,
|
||||
tags: this.activityForm.get('tags').value,
|
||||
type: this.activityForm.get('type').value,
|
||||
unitPrice: this.activityForm.get('unitPrice').value
|
||||
|
Loading…
x
Reference in New Issue
Block a user