Improve debug for artist

This commit is contained in:
2018-01-14 03:32:26 +01:00
parent 9e81d42cb3
commit 66a1cd12e0
3 changed files with 27 additions and 2 deletions

View File

@@ -3,10 +3,14 @@
<div class="alert alert-warning">
<h3>Debug Zone</h3>
Returned song: {{songs.length}}<br />
Theorical song: {{ artist ? artist['Track Count'] : "" }}
Returned song:&emsp;{{songs.length}}<br />
Theorical song:&emsp;{{ artist ? artist['Track Count'] : "" }}
<span *ngIf="artist && (songs.length == artist['Track Count'])" class="glyphicon glyphicon-ok" style="color:green"></span>
<span *ngIf="artist && (songs.length != artist['Track Count'])" class="glyphicon glyphicon-remove" style="color:red"></span>
<br />
Artist song:&emsp;&emsp;&emsp;{{countSong}}
<span *ngIf="artist && (songs.length == countSong)" class="glyphicon glyphicon-ok" style="color:green"></span>
<span *ngIf="artist && (songs.length != countSong)" class="glyphicon glyphicon-remove" style="color:red"></span>
</div>
<div class="row cardAdmin">

View File

@@ -24,6 +24,7 @@ export class ArtistComponent implements OnInit {
songs: Array<Song> = [];
artist: Artist = new Artist();
lockLoadData = false;
countSong: number;
constructor(
private elsService: ElsService,
@@ -35,6 +36,9 @@ export class ArtistComponent implements OnInit {
this.route.params.subscribe((params: Params) => this.artistName = params['name']);
this.elsService.getArtist(this.artistName).subscribe(data => this.artist = data);
this.elsService.getCountArtistSong(this.artistName).subscribe(data => this.countSong = data);
this.loadSongs();
}

View File

@@ -269,6 +269,23 @@ export class ElsService {
});
}
getCountArtistSong(artistName: string): Observable<number> {
console.log('artistname: ' + artistName);
return this.http
.post(this.elsUrl + 'song' + ElsService.ACTION_COUNT,
JSON.stringify({
'query': {
'bool': {
'should': [
{'match_phrase' : { 'Album Artist' : artistName }},
{'match_phrase' : { 'Artist' : artistName }}
]
}
}
}), {headers: this.headers})
.map(res => res.json().count as number);
}
/** Process a result to return just one result.
* Used to get an album or an artist.
* Take a name to put in console output if no result or more than one result.