diff --git a/dashboard/src/app/els.service.ts b/dashboard/src/app/els.service.ts index 39f595f..7a3e23f 100644 --- a/dashboard/src/app/els.service.ts +++ b/dashboard/src/app/els.service.ts @@ -101,8 +101,6 @@ export class ElsService { getMostPlayedTrack(): Observable { // Thank to http://chariotsolutions.com/blog/post/angular2-observables-http-separating-services-components/ // for the map part - - // Could be shorter but I think it's more readable like this. return this.http .post(this.elsUrl + 'song' + ElsService.ACTION_SEARCH, JSON.stringify({ @@ -114,23 +112,12 @@ export class ElsService { 'size': 5 }), {headers: this.headers}) .map(res => { - return res.json().hits.hits; - }) - .map((hits: Array) => { const result: Array = []; - hits.forEach((hit) => { - result.push(hit._source); + res.json().hits.hits.forEach(element => { + result.push(element._source); }); return result; }); - // Shorter way: - // .map(res => { - // let result: Array = []; - // res.json().hits.hits.forEach(element => { - // result.push(element._source); - // }); - // return result; - // }); } getAlbumSongs(albumName: string, from: number = 0): Observable { @@ -145,11 +132,8 @@ export class ElsService { 'from': from }), {headers: this.headers}) .map(res => { - return res.json().hits.hits; - }) - .map((hits: Array) => { const result: Array = []; - hits.forEach((hit) => { + res.json().hits.hits.forEach((hit) => { result.push(hit._source); }); return result; @@ -169,11 +153,8 @@ export class ElsService { 'from': from }), {headers: this.headers}) .map(res => { - return res.json().hits.hits; - }) - .map((hits: Array) => { const result: Array = []; - hits.forEach((hit) => { + res.json().hits.hits.forEach((hit) => { result.push(hit._source); }); return result; @@ -197,11 +178,8 @@ export class ElsService { 'from': from }), {headers: this.headers}) .map(res => { - return res.json().hits.hits; - }) - .map((hits: Array) => { const result: Array = []; - hits.forEach((hit) => { + res.json().hits.hits.forEach((hit) => { result.push(hit._source); }); return result; @@ -310,7 +288,7 @@ export class ElsService { 'album' : { 'terms' : { 'field' : 'Album.original', - 'size': 10 + 'size': 150 } } },