Merge branch '599-wrong-track-count' into 'develop'
Fix #599: wrong album/track count on artist page Closes #599 See merge request funkwhale/funkwhale!460
This commit is contained in:
commit
109b801961
|
@ -0,0 +1 @@
|
||||||
|
Fixed wrong album/track count on artist page (#599)
|
|
@ -94,6 +94,8 @@ export default {
|
||||||
isLoadingAlbums: true,
|
isLoadingAlbums: true,
|
||||||
artist: null,
|
artist: null,
|
||||||
albums: null,
|
albums: null,
|
||||||
|
totalTracks: 0,
|
||||||
|
totalAlbums: 0,
|
||||||
tracks: []
|
tracks: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -107,12 +109,14 @@ export default {
|
||||||
logger.default.debug('Fetching artist "' + this.id + '"')
|
logger.default.debug('Fetching artist "' + this.id + '"')
|
||||||
axios.get('tracks/', {params: {artist: this.id}}).then((response) => {
|
axios.get('tracks/', {params: {artist: this.id}}).then((response) => {
|
||||||
self.tracks = response.data.results
|
self.tracks = response.data.results
|
||||||
|
self.totalTracks = response.data.count
|
||||||
})
|
})
|
||||||
axios.get('artists/' + this.id + '/').then((response) => {
|
axios.get('artists/' + this.id + '/').then((response) => {
|
||||||
self.artist = response.data
|
self.artist = response.data
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
self.isLoadingAlbums = true
|
self.isLoadingAlbums = true
|
||||||
axios.get('albums/', {params: {artist: self.id, ordering: '-release_date'}}).then((response) => {
|
axios.get('albums/', {params: {artist: self.id, ordering: '-release_date'}}).then((response) => {
|
||||||
|
self.totalAlbums = response.data.count
|
||||||
let parsed = JSON.parse(JSON.stringify(response.data.results))
|
let parsed = JSON.parse(JSON.stringify(response.data.results))
|
||||||
self.albums = parsed.map((album) => {
|
self.albums = parsed.map((album) => {
|
||||||
return backend.Album.clean(album)
|
return backend.Album.clean(album)
|
||||||
|
@ -129,22 +133,6 @@ export default {
|
||||||
title: this.$gettext('Artist')
|
title: this.$gettext('Artist')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
totalAlbums () {
|
|
||||||
let trackAlbums = _.uniqBy(this.tracks, (t) => {
|
|
||||||
return t.album.id
|
|
||||||
})
|
|
||||||
return this.albums.length + trackAlbums.length
|
|
||||||
},
|
|
||||||
totalTracks () {
|
|
||||||
if (this.albums.length === 0) {
|
|
||||||
return 0 + this.tracks.length
|
|
||||||
}
|
|
||||||
return this.albums.map((album) => {
|
|
||||||
return album.tracks.length
|
|
||||||
}).reduce((a, b) => {
|
|
||||||
return a + b
|
|
||||||
}) + this.tracks.length
|
|
||||||
},
|
|
||||||
isPlayable () {
|
isPlayable () {
|
||||||
return this.artist.albums.filter((a) => {
|
return this.artist.albums.filter((a) => {
|
||||||
return a.is_playable
|
return a.is_playable
|
||||||
|
|
Loading…
Reference in New Issue