Fix: proper subsonic album listenings count

623-test
Marcos Peña 2021-11-10 21:18:13 +01:00 zatwierdzone przez JuniorJPDJ
rodzic 2335e4530c
commit fe7a14fec9
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -149,7 +149,7 @@ def get_album2_data(album):
"artist": album.artist.name,
"created": to_subsonic_date(album.creation_date),
"duration": album.tracks.aggregate(d=Sum("uploads__duration"))["d"] or 0,
"playCount": album.tracks.aggregate(c=Sum("downloads_count"))["c"] or 0,
"playCount": album.tracks.aggregate(l=Count("listenings"))["l"] or 0,
}
if album.attachment_cover_id:
payload["coverArt"] = "al-{}".format(album.id)

Wyświetl plik

@ -1,6 +1,6 @@
import datetime
from django.db.models.aggregates import Sum
from django.db.models.aggregates import Count, Sum
import pytest
from funkwhale_api.music import models as music_models
@ -186,7 +186,7 @@ def test_get_album_serializer(factories):
"coverArt": "al-{}".format(album.id),
"genre": tagged_item.tag.name,
"duration": album.tracks.aggregate(d=Sum("uploads__duration"))["d"] or 0,
"playCount": album.tracks.aggregate(c=Sum("downloads_count"))["c"] or 0,
"playCount": album.tracks.aggregate(l=Count("listenings"))["l"] or 0,
"song": [
{
"id": track.pk,