Little improve service (code style)
This commit is contained in:
@@ -118,7 +118,8 @@ export class ElsService {
|
|||||||
console.debug("getArtistSongs- Artist name: " + artistName + " - from: " + from);
|
console.debug("getArtistSongs- Artist name: " + artistName + " - from: " + from);
|
||||||
return this.http
|
return this.http
|
||||||
.post(this.elsUrl + "song/_search",
|
.post(this.elsUrl + "song/_search",
|
||||||
JSON.stringify({
|
JSON.stringify(
|
||||||
|
{
|
||||||
"query": {
|
"query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"should": [
|
"should": [
|
||||||
@@ -157,7 +158,7 @@ export class ElsService {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (hits.length > 1) {
|
if (hits.length > 1) {
|
||||||
console.error('More than one album "' + albumName + '" found, return the first.');
|
console.error('More than one album "' + albumName + '" found (' + hits.length + '), return the first.');
|
||||||
}
|
}
|
||||||
return hits[0]._source;
|
return hits[0]._source;
|
||||||
});
|
});
|
||||||
@@ -172,12 +173,13 @@ export class ElsService {
|
|||||||
.map((hits: Array<any>) => {
|
.map((hits: Array<any>) => {
|
||||||
// Theorically, my script prevent to found two documents with this query.
|
// Theorically, my script prevent to found two documents with this query.
|
||||||
// But Prevention is better than cure as Shakespeare said
|
// But Prevention is better than cure as Shakespeare said
|
||||||
|
console.log(hits.length);
|
||||||
if (hits.length < 1) {
|
if (hits.length < 1) {
|
||||||
console.info('No artist "' + artistName + '" found.');
|
console.info('No artist "' + artistName + '" found.');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (hits.length > 1) {
|
if (hits.length > 1) {
|
||||||
console.error('More than one artist "' + artistName + '" found, return the first.');
|
console.error('More than one artist "' + artistName + '" found (' + hits.length + '), return the first.');
|
||||||
console.error('This is not normal!')
|
console.error('This is not normal!')
|
||||||
}
|
}
|
||||||
return hits[0]._source;
|
return hits[0]._source;
|
||||||
|
|||||||
Reference in New Issue
Block a user