Last added: Refactor identification of good album
This commit is contained in:
@@ -71,20 +71,25 @@ export class DashboardComponent implements OnInit {
|
|||||||
// For each bucket.key (album name), search artist.
|
// For each bucket.key (album name), search artist.
|
||||||
// Use track count to compare
|
// Use track count to compare
|
||||||
this.elsService.getArtistFromAlbumName(albumBucket.key).subscribe(albums => {
|
this.elsService.getArtistFromAlbumName(albumBucket.key).subscribe(albums => {
|
||||||
|
// Identification of the good album
|
||||||
|
let goodAlbum;
|
||||||
if (albums.length > 1) {
|
if (albums.length > 1) {
|
||||||
// More than one result for an album name
|
// More than one result for an album name: search good by track count
|
||||||
// Search good artist by track count
|
|
||||||
albums.forEach(album => {
|
albums.forEach(album => {
|
||||||
if (album['Track Count'] === albumBucket.doc_count) {
|
if (album['Track Count'] === albumBucket.doc_count) {
|
||||||
this.albumArtists[album.Name] = album['Album Artist'] ? album['Album Artist'].toString() : album.Artist.toString();
|
goodAlbum = album;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Just one artistresult for album name
|
// Just one result for album name
|
||||||
this.albumArtists[albums[0].Name] = albums[0]['Album Artist'] ? albums[0]['Album Artist'].toString() : albums[0].Artist.toString();
|
goodAlbum = albums[0];
|
||||||
}
|
}
|
||||||
if (this.albumArtists[albums[0].Name].length > 50) {
|
|
||||||
this.albumArtists[albums[0].Name] = this.albumArtists[albums[0].Name].substring(0, 50) + '...';
|
this.albumArtists[goodAlbum.Name] = goodAlbum['Album Artist'] ? goodAlbum['Album Artist'].toString() : goodAlbum.Artist.toString();
|
||||||
|
|
||||||
|
// If an album with multiple artist doesn't have 'Album Artist' field - this case should not happen
|
||||||
|
if (this.albumArtists[goodAlbum.Name].length > 50) {
|
||||||
|
this.albumArtists[goodAlbum.Name] = this.albumArtists[goodAlbum.Name].substring(0, 50) + '...';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user