mirror of
https://github.com/koel/koel
synced 2025-02-26 12:17:12 +00:00
Exclude unknown artist/album from most-played
This commit is contained in:
parent
37b46eb922
commit
82ce986405
2 changed files with 10 additions and 10 deletions
|
@ -147,11 +147,11 @@ export default {
|
||||||
* @return {Array.<Object>}
|
* @return {Array.<Object>}
|
||||||
*/
|
*/
|
||||||
getMostPlayed(n = 6) {
|
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
|
return _.take(_.sortByOrder(applicable, 'playCount', 'desc'), n);
|
||||||
_.remove(albums, album => !album.playCount);
|
|
||||||
|
|
||||||
return albums;
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,11 +150,11 @@ export default {
|
||||||
* @return {Array.<Object>}
|
* @return {Array.<Object>}
|
||||||
*/
|
*/
|
||||||
getMostPlayed(n = 6) {
|
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
|
return _.take(_.sortByOrder(applicable, 'playCount', 'desc'), n);
|
||||||
_.remove(artists, artist => !artist.playCount);
|
|
||||||
|
|
||||||
return artists;
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue