Exclude unknown artist/album from most-played

This commit is contained in:
An Phan 2016-03-06 17:06:28 +08:00
parent 37b46eb922
commit 82ce986405
2 changed files with 10 additions and 10 deletions

View file

@ -147,11 +147,11 @@ export default {
* @return {Array.<Object>}
*/
getMostPlayed(n = 6) {
var albums = _.take(_.sortByOrder(this.state.albums, 'playCount', 'desc'), n);
// Only non-unknown albums with actually play count are applicable.
var applicable = _.filter(this.state.albums, album => {
return album.playCount && album.id !== 1;
});
// Remove those with playCount=0
_.remove(albums, album => !album.playCount);
return albums;
return _.take(_.sortByOrder(applicable, 'playCount', 'desc'), n);
},
};

View file

@ -150,11 +150,11 @@ export default {
* @return {Array.<Object>}
*/
getMostPlayed(n = 6) {
var artists = _.take(_.sortByOrder(this.state.artists, 'playCount', 'desc'), n);
// Only non-unknown artists with actually play count are applicable.
var applicable = _.filter(this.state.artists, artist => {
return artist.playCount && artist.id !== 1;
});
// Remove those with playCount=0
_.remove(artists, artist => !artist.playCount);
return artists;
return _.take(_.sortByOrder(applicable, 'playCount', 'desc'), n);
},
};