Small performance enhancements

This commit is contained in:
Eliot Berriot 2019-10-22 11:44:38 +02:00
parent 5623b6d88b
commit 1ca7f62aab
No known key found for this signature in database
GPG key ID: 6B501DFD73514E14
2 changed files with 52 additions and 81 deletions

View file

@ -436,7 +436,7 @@ class TrackQuerySet(common_models.LocalFromFidQuerySet, models.QuerySet):
return self.exclude(pk__in=matches)
def with_playable_uploads(self, actor):
uploads = Upload.objects.playable_by(actor).select_related("track")
uploads = Upload.objects.playable_by(actor)
return self.prefetch_related(
models.Prefetch("uploads", queryset=uploads, to_attr="playable_uploads")
)
@ -594,7 +594,8 @@ class Track(APIModelMixin):
@property
def listen_url(self):
return reverse("api:v1:listen-detail", kwargs={"uuid": self.uuid})
# Not using reverse because this is slow
return "/api/v1/listen/{}/".format(self.uuid)
@property
def local_license(self):