Verified Commit c8702ca7 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fx #986: Fixed invalid displayed number of tracks in playlist

parent 8cf003ab
Pipeline #8290 passed with stages
in 4 minutes and 25 seconds
......@@ -24,7 +24,7 @@ class PlaylistViewSet(
queryset = (
models.Playlist.objects.all()
.select_related("user__actor")
.annotate(tracks_count=Count("playlist_tracks"))
.annotate(tracks_count=Count("playlist_tracks", distinct=True))
.with_covers()
.with_duration()
)
......
......@@ -25,6 +25,18 @@ def test_serializer_includes_tracks_count(factories, logged_in_api_client):
assert response.data["tracks_count"] == 1
def test_serializer_includes_tracks_count_986(factories, logged_in_api_client):
playlist = factories["playlists.Playlist"]()
plt = factories["playlists.PlaylistTrack"](playlist=playlist)
factories["music.Upload"].create_batch(
3, track=plt.track, library__privacy_level="everyone", import_status="finished"
)
url = reverse("api:v1:playlists-detail", kwargs={"pk": playlist.pk})
response = logged_in_api_client.get(url)
assert response.data["tracks_count"] == 1
def test_serializer_includes_is_playable(factories, logged_in_api_client):
playlist = factories["playlists.Playlist"]()
factories["playlists.PlaylistTrack"](playlist=playlist)
......
Fixed invalid displayed number of tracks in playlist (#986)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment