TOSQUASH Continue refactoring with function
This commit is contained in:
@@ -171,19 +171,20 @@ export class ElsService {
|
|||||||
},
|
},
|
||||||
'size': ElsService.DEFAULT_SIZE
|
'size': ElsService.DEFAULT_SIZE
|
||||||
}), {headers: this.headers})
|
}), {headers: this.headers})
|
||||||
.map(res => {
|
.map(res => this.responseToAlbum(res, albumName));
|
||||||
return res.json().hits.hits;
|
}
|
||||||
})
|
|
||||||
.map((hits: Array<any>) => {
|
private responseToAlbum(res: Response, name: string): Album {
|
||||||
if (hits.length < 1) {
|
const hits = res.json().hits.hits;
|
||||||
console.info('No album "' + albumName + '" found.');
|
if (hits.length < 1) {
|
||||||
return undefined;
|
console.info('No album "' + name + '" found.');
|
||||||
}
|
return undefined;
|
||||||
if (hits.length > 1) {
|
}
|
||||||
console.error('More than one album "' + albumName + '" found (' + hits.length + '), return the first.');
|
if (hits.length > 1) {
|
||||||
}
|
// TODO Cumul results
|
||||||
return hits[0]._source;
|
console.error('More than one album "' + name + '" found (' + hits.length + '), return the first.');
|
||||||
});
|
}
|
||||||
|
return hits[0]._source;
|
||||||
}
|
}
|
||||||
|
|
||||||
getArtist(artistName: string): Observable<Artist> {
|
getArtist(artistName: string): Observable<Artist> {
|
||||||
|
|||||||
Reference in New Issue
Block a user