Improve debug for artist
This commit is contained in:
@@ -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: {{songs.length}}<br />
|
||||
Theorical song: {{ 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:   {{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">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user