mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 18:09:33 +02:00
Add number of tracks and discs of an album to API
This commit is contained in:
parent
b011db2bb4
commit
b321ab8da2
4 changed files with 43 additions and 1 deletions
|
@ -20,6 +20,7 @@ from django.db.models.signals import post_save, pre_save
|
|||
from django.dispatch import receiver
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.db.models import Prefetch, Count
|
||||
|
||||
from funkwhale_api import musicbrainz
|
||||
from funkwhale_api.common import fields
|
||||
|
@ -420,7 +421,13 @@ def import_album(v):
|
|||
class TrackQuerySet(common_models.LocalFromFidQuerySet, models.QuerySet):
|
||||
def for_nested_serialization(self):
|
||||
return self.prefetch_related(
|
||||
"artist", "album__artist", "album__attachment_cover"
|
||||
"artist",
|
||||
Prefetch(
|
||||
"album",
|
||||
queryset=Album.objects.select_related(
|
||||
"artist", "attachment_cover"
|
||||
).annotate(_prefetched_tracks_count=Count("tracks")),
|
||||
),
|
||||
)
|
||||
|
||||
def annotate_playable_by_actor(self, actor):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue