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[] }> {
|
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||||
let items: LookupItem[] = [];
|
let items: LookupItem[] = [];
|
||||||
|
|
||||||
if (aQuery.length <= 2) {
|
|
||||||
return { items };
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const get = bent(
|
const get = bent(
|
||||||
`${this.URL}/search?query=${aQuery}`,
|
`${this.URL}/search?query=${aQuery}`,
|
||||||
|
@ -264,6 +264,10 @@ export class DataProviderService {
|
|||||||
const promises: Promise<{ items: LookupItem[] }>[] = [];
|
const promises: Promise<{ items: LookupItem[] }>[] = [];
|
||||||
let lookupItems: LookupItem[] = [];
|
let lookupItems: LookupItem[] = [];
|
||||||
|
|
||||||
|
if (aQuery?.length < 2) {
|
||||||
|
return { items: lookupItems };
|
||||||
|
}
|
||||||
|
|
||||||
for (const dataSource of this.configurationService.get('DATA_SOURCES')) {
|
for (const dataSource of this.configurationService.get('DATA_SOURCES')) {
|
||||||
promises.push(
|
promises.push(
|
||||||
this.getDataProvider(DataSource[dataSource]).search(aQuery)
|
this.getDataProvider(DataSource[dataSource]).search(aQuery)
|
||||||
|
@ -158,10 +158,6 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
public async search(aQuery: string): Promise<{ items: LookupItem[] }> {
|
||||||
let items: LookupItem[] = [];
|
let items: LookupItem[] = [];
|
||||||
|
|
||||||
if (aQuery.length <= 2) {
|
|
||||||
return { items };
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const get = bent(
|
const get = bent(
|
||||||
`${this.URL}/search/${aQuery}?api_token=${this.apiKey}`,
|
`${this.URL}/search/${aQuery}?api_token=${this.apiKey}`,
|
||||||
|
@ -243,11 +243,10 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
|
|||||||
this.filteredLookupItemsObservable = this.activityForm.controls[
|
this.filteredLookupItemsObservable = this.activityForm.controls[
|
||||||
'searchSymbol'
|
'searchSymbol'
|
||||||
].valueChanges.pipe(
|
].valueChanges.pipe(
|
||||||
startWith(''),
|
|
||||||
debounceTime(400),
|
debounceTime(400),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
switchMap((query: string) => {
|
switchMap((query: string) => {
|
||||||
if (isString(query)) {
|
if (isString(query) && query.length > 1) {
|
||||||
const filteredLookupItemsObservable =
|
const filteredLookupItemsObservable =
|
||||||
this.dataService.fetchSymbols(query);
|
this.dataService.fetchSymbols(query);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user