Reduce search requests (#1786)

This commit is contained in:
Thomas Kaul 2023-03-12 14:29:22 +01:00 committed by GitHub
parent 7c6ff776d9
commit 0d92b8d8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 10 deletions

View File

@ -163,10 +163,6 @@ export class CoinGeckoService implements DataProviderInterface {
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
let items: LookupItem[] = [];
if (aQuery.length <= 2) {
return { items };
}
try {
const get = bent(
`${this.URL}/search?query=${aQuery}`,

View File

@ -264,6 +264,10 @@ export class DataProviderService {
const promises: Promise<{ items: LookupItem[] }>[] = [];
let lookupItems: LookupItem[] = [];
if (aQuery?.length < 2) {
return { items: lookupItems };
}
for (const dataSource of this.configurationService.get('DATA_SOURCES')) {
promises.push(
this.getDataProvider(DataSource[dataSource]).search(aQuery)

View File

@ -158,10 +158,6 @@ export class EodHistoricalDataService implements DataProviderInterface {
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
let items: LookupItem[] = [];
if (aQuery.length <= 2) {
return { items };
}
try {
const get = bent(
`${this.URL}/search/${aQuery}?api_token=${this.apiKey}`,

View File

@ -243,11 +243,10 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.filteredLookupItemsObservable = this.activityForm.controls[
'searchSymbol'
].valueChanges.pipe(
startWith(''),
debounceTime(400),
distinctUntilChanged(),
switchMap((query: string) => {
if (isString(query)) {
if (isString(query) && query.length > 1) {
const filteredLookupItemsObservable =
this.dataService.fetchSymbols(query);