Reduce search requests (#1786)
This commit is contained in:
parent
7c6ff776d9
commit
0d92b8d8bb
@ -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}`,
|
||||
|
@ -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)
|
||||
|
@ -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}`,
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user