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
|
### 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 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 support to import activities by `isin` in the _Yahoo Finance_ service
|
||||||
- Improved the language localization for Polish (`pl`)
|
- Improved the language localization for Polish (`pl`)
|
||||||
|
@ -618,7 +618,8 @@ export class DataProviderService {
|
|||||||
promises.push(
|
promises.push(
|
||||||
dataProviderService.search({
|
dataProviderService.search({
|
||||||
includeIndices,
|
includeIndices,
|
||||||
query
|
query,
|
||||||
|
userId: user.id
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -79,4 +79,5 @@ export interface GetQuotesParams {
|
|||||||
export interface GetSearchParams {
|
export interface GetSearchParams {
|
||||||
includeIndices?: boolean;
|
includeIndices?: boolean;
|
||||||
query: string;
|
query: string;
|
||||||
|
userId?: string;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import {
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { DataSource, SymbolProfile } from '@prisma/client';
|
import { DataSource, SymbolProfile } from '@prisma/client';
|
||||||
import * as cheerio from 'cheerio';
|
import * as cheerio from 'cheerio';
|
||||||
import { isUUID } from 'class-validator';
|
|
||||||
import { addDays, format, isBefore } from 'date-fns';
|
import { addDays, format, isBefore } from 'date-fns';
|
||||||
import got, { Headers } from 'got';
|
import got, { Headers } from 'got';
|
||||||
import * as jsonpath from 'jsonpath';
|
import * as jsonpath from 'jsonpath';
|
||||||
@ -219,41 +218,48 @@ export class ManualService implements DataProviderInterface {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async search({ query }: GetSearchParams): Promise<LookupResponse> {
|
public async search({
|
||||||
let items = await this.prismaService.symbolProfile.findMany({
|
query,
|
||||||
|
userId
|
||||||
|
}: GetSearchParams): Promise<LookupResponse> {
|
||||||
|
const items = await this.prismaService.symbolProfile.findMany({
|
||||||
select: {
|
select: {
|
||||||
assetClass: true,
|
assetClass: true,
|
||||||
assetSubClass: true,
|
assetSubClass: true,
|
||||||
currency: true,
|
currency: true,
|
||||||
dataSource: true,
|
dataSource: true,
|
||||||
name: true,
|
name: true,
|
||||||
symbol: true
|
symbol: true,
|
||||||
|
userId: true
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
AND: [
|
||||||
{
|
{
|
||||||
dataSource: this.getName(),
|
dataSource: this.getName()
|
||||||
name: {
|
|
||||||
mode: 'insensitive',
|
|
||||||
startsWith: query
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dataSource: this.getName(),
|
OR: [
|
||||||
symbol: {
|
{
|
||||||
mode: 'insensitive',
|
name: {
|
||||||
startsWith: query
|
mode: 'insensitive',
|
||||||
}
|
startsWith: query
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
symbol: {
|
||||||
|
mode: 'insensitive',
|
||||||
|
startsWith: query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
OR: [{ userId }, { userId: null }]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
items = items.filter(({ symbol }) => {
|
|
||||||
// Remove UUID symbols (activities of type ITEM)
|
|
||||||
return !isUUID(symbol);
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: items.map((item) => {
|
items: items.map((item) => {
|
||||||
return { ...item, dataProviderInfo: this.getDataProviderInfo() };
|
return { ...item, dataProviderInfo: this.getDataProviderInfo() };
|
||||||
|
@ -20,7 +20,6 @@ import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
|||||||
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { AssetClass, AssetSubClass, Tag, Type } from '@prisma/client';
|
import { AssetClass, AssetSubClass, Tag, Type } from '@prisma/client';
|
||||||
import { isUUID } from 'class-validator';
|
|
||||||
import { isAfter, isToday } from 'date-fns';
|
import { isAfter, isToday } from 'date-fns';
|
||||||
import { EMPTY, Observable, Subject, lastValueFrom, of } from 'rxjs';
|
import { EMPTY, Observable, Subject, lastValueFrom, of } from 'rxjs';
|
||||||
import { catchError, delay, map, startWith, takeUntil } from 'rxjs/operators';
|
import { catchError, delay, map, startWith, takeUntil } from 'rxjs/operators';
|
||||||
@ -476,10 +475,8 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
fee: this.activityForm.get('fee').value,
|
fee: this.activityForm.get('fee').value,
|
||||||
quantity: this.activityForm.get('quantity').value,
|
quantity: this.activityForm.get('quantity').value,
|
||||||
symbol:
|
symbol:
|
||||||
this.activityForm.get('searchSymbol').value?.symbol === undefined ||
|
this.activityForm.get('searchSymbol')?.value?.symbol ??
|
||||||
isUUID(this.activityForm.get('searchSymbol').value?.symbol)
|
this.activityForm.get('name')?.value,
|
||||||
? this.activityForm.get('name').value
|
|
||||||
: this.activityForm.get('searchSymbol').value.symbol,
|
|
||||||
tags: this.activityForm.get('tags').value,
|
tags: this.activityForm.get('tags').value,
|
||||||
type: this.activityForm.get('type').value,
|
type: this.activityForm.get('type').value,
|
||||||
unitPrice: this.activityForm.get('unitPrice').value
|
unitPrice: this.activityForm.get('unitPrice').value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user