Browse Source
			
			
			Feature/improve search functionality for multiple data sources (#374)
			
				* Improve search functionality for multiple data sources
* Update changelog
			
			
				pull/375/head
			
			
		 
		
			
				
					
						
						Thomas Kaul
					
					4 years ago
					
						
							committed by
							
								
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
17 additions and 
5 deletions
			 
			
		 
		
			
				- 
					
					
					 
					CHANGELOG.md
				
 
			
				- 
					
					
					 
					apps/api/src/services/data-provider/data-provider.service.ts
				
 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					### Changed | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					- Respected the data source attribute in the symbol data endpoint | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					- Improved the search functionality of the data management (multiple data sources) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					## 1.53.0 - 13.09.2021 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -150,13 +150,24 @@ export class DataProviderService { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public async search(aSymbol: string): Promise<{ items: LookupItem[] }> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const { items } = await this.getDataProvider( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      <DataSource>this.configurationService.get('DATA_SOURCES')[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ).search(aSymbol); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const promises: Promise<{ items: LookupItem[] }>[] = []; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let lookupItems: LookupItem[] = []; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const filteredItems = items.filter((item) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    for (const dataSource of this.configurationService.get('DATA_SOURCES')) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      promises.push( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.getDataProvider(DataSource[dataSource]).search(aSymbol) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const searchResults = await Promise.all(promises); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    searchResults.forEach((searchResult) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      lookupItems = lookupItems.concat(searchResult.items); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const filteredItems = lookupItems.filter((lookupItem) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // Only allow symbols with supported currency
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return item.currency ? true : false; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return lookupItem.currency ? true : false; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |